-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
Hi i'm trying to list all the commit in a specific branch via python from azure devops but getting this error, 'dict' object has no attribute 'ids'
. I'm using get_commits
function here is my sample code.
import os
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from git import Repo, GitCommandError
class AzureDevOpsGitManager:
def __init__(self, organization, project, repo_name, pat):
self.organization = organization
self.project = project
self.repo_name = repo_name
self.credentials = BasicAuthentication('', pat)
self.connection = Connection(base_url=f'https://dev.azure.com/{organization}', creds=self.credentials)
self.git_client = self.connection.clients.get_git_client()
def list_commits(self, branch_name='main'):
commits = self.git_client.get_commits(repository_id=self.repo_name, project=self.project_name, search_criteria={'itemVersion': {'version': branch_name}})
return [(commit.commit_id, commit.author.name, commit.comment) for commit in commits]
Any idea why i'm getting the above error.
Activity
MarwinMarw commentedon Apr 11, 2025
Use
GitQueryCommitsCriteria
class to build search criteria fromazure.devops.v7_1.git.models