Skip to content

AttributeError: 'dict' object has no attribute 'version_type' when trying to use git_client.get_commits search_criteria #526

Open
@SCMSADMIN

Description

@SCMSADMIN

When trying to get all the commits on a branch I get an attribute error.

Code:
from azure.devops.connection import Connection
from azure.devops.v7_0.git import GitClient
from azure.devops.v7_0.git.models import GitQueryCommitsCriteria
from msrest.authentication import BasicAuthentication

cm_search_criteria = GitQueryCommitsCriteria(
item_version={"version": branch_name,"versionType": 'branch'}
)

        print (f"search critera")
        print (cm_search_criteria)
        print (f"search critera")
        
        commits = git_client.get_commits(
            repo_name,
            project=project_name,
            search_criteria=cm_search_criteria
        )    

Results:
Traceback (most recent call last):
File "C:\PythonWork\Tool Connectivity\ADO_ALL_REPOS_BRANCHES_COMMITS.py", line 66, in
commits = git_client.get_commits(
repo_name,
project=project_name,
search_criteria=cm_search_criteria
)
File "C:\Users\tmoran\AppData\Local\Programs\Python\Python313\Lib\site-packages\azure\devops\v7_0\git\git_client_base.py", line 361, in get_commits
if search_criteria.item_version.version_type is not None:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'version_type'

I cannot see anything wrong with the code, but it is throwing an error, does any one see an error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions