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 摘要。