microsoft / microsoft/azure-devops-python-api

Getting incorrect return from get_commit_diffs()

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

還沒有人認領這個 Issue。

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

描述

I'm trying to get the diff between two commit, therefore using this API as,

            ref_heads = git_client.get_refs(repository_id=REPOSITORY_ID, project=PROJECT_NAME, filter=target_branch)
            master_commit_id = ref_heads.value[0].object_id
            source_commit_id = pull_request.last_merge_source_commit.commit_id

            base_version_descriptor = GitBaseVersionDescriptor(version_type='commit', version=master_commit_id)
            target_version_descriptor = GitTargetVersionDescriptor(version_type='commit', version=source_commit_id)

            commit_diffs = git_client.get_commit_diffs(repository_id=REPOSITORY_ID, project=PROJECT_NAME,
                                                       diff_common_commit=True,
                                                        base_version_descriptor=base_version_descriptor,
                                                        target_version_descriptor=target_version_descriptor)

while print the commit_diffs, having output as,

Diffs Response: {'additional_properties': {}, 'ahead_count': 0, 'all_changes_included': True, 'base_commit': 'b106b44eebeef93d5240f08dca8ceb0124ca4415', 'behind_count': 0, 'change_counts': {}, 'changes': [], 'common_commit': 'b106b44eebeef93d5240f08dca8ceb0124ca4415', 'target_commit': 'b106b44eebeef93d5240f08dca8ceb0124ca4415'}

whereas, using curl to set direct REST request, returns correct output.

"https://dev.azure.com/ORGANIZATION/project/_apis/git/repositories/a21206d3-9bdb-41c4-8b77-56f82360a311e/diffs/commits?baseVersionType=commit&baseVersion=b106b44eebeef93d5240f08dca8ceb0124ca4415&targetVersionType=commit&targetVersion=165c197e54d689e9910eb111b9c14e2516184dd8&api-version=6.0"

What is the correct way to use the get_commit_diff()? Or what I'm doing wrong?

貢獻指南

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

從這裡開始

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

研究方向

從 get_commit_diffs() 入口開始,將 Python 引數與 issue 中顯示的 REST 請求進行比較,尤其是基礎提交與目標提交描述元。重現此呼叫,並驗證回傳的 base_commit、target_commit 與 changes 是否與直接的 REST 回應一致;當 Python API 回傳預期的 diff 時即表示完成。

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

評估

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

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

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