microsoft / microsoft/azure-devops-python-api
AttributeError: 'dict' object has no attribute 'version_type' when trying to use git_client.get_commits search_criteria
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 684
- 分支
- 218
- 平均合併
- 8 天 10 小時
- 30 天內合併 PR
- 1
描述
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?
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 azure/devops/v7_0/git/git_client_base.py 第 361 行附近以及 get_commits 使用的 GitQueryCommitsCriteria 模型開始。將預期的 item_version 模型結構與範例中提供的字典進行比較。完成標準是:可以將分支條件傳遞給 get_commits 而不會出現 AttributeError,並且提交查詢能夠完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- azure, python
- 領域
- api, devops
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100