microsoft / microsoft/azure-devops-python-api

'dict' object has no attribute 'ids'

未關閉
#502 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
684
分支
218
平均合併
8 天 10 小時
30 天內合併 PR
1

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 list_commits 開始,將 get_commits 呼叫與 Azure DevOps Python API 的回應結構進行比較,特別注意 search_criteria 引數,以及使用 project_name 而不是 project。使用提供的範例重現錯誤,並在對回傳值進行迭代之前檢查它。完成標準是:可以使用 commit_id、author.name 和 comment 列出分支提交,且不會出現屬性錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
azure, git, python
領域
api
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。