gpt4 book ai didi

Azure DevOps API - 从 master 创建新分支而不添加更改

转载 作者:行者123 更新时间:2023-12-02 05:59:13 24 4
gpt4 key购买 nike

我正在尝试使用 Azure DevOps Services Rest API 从 master 创建一个新分支,但没有成功。

文档:https://learn.microsoft.com/en-us/rest/api/azure/devops/git/refs/update-refs?view=azure-devops-rest-5.1#examples

端点:https://dev.azure.com/{{organization}}/{{project}}/_apis/git/repositories/{{repositoryId}}/refs?api-version={{api-version}}

正文:

[
{
"name": "refs/heads/new-test-branch-from-api-call",
"oldObjectId": "{{masterObjectId}}",
"newObjectId": "{{newObjectId}}"
}
]

结果:

{
"$id": "1",
"innerException": null,
"message": "TF401035: The object '****************************************' does not exist.",
"typeName": "Microsoft.TeamFoundation.Git.Server.GitObjectDoesNotExistException, Microsoft.TeamFoundation.Git.Server",
"typeKey": "GitObjectDoesNotExistException",
"errorCode": 0,
"eventId": 3000
}

this的评论帖子指出这是要走的路线。还指出应使用 repositoryIdnewObjectId ,这会导致:

{
"$id": "1",
"innerException": null,
"message": "An object ID must be 40 characters long and only have hex digits. Passed in object ID: ********-****-****-****-************.",
"typeName": "System.ArgumentException, mscorlib",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}

最佳答案

newObjectId 是现有分支的对象 ID。真的不知道为什么它实际上是旧的而被命名为新的。非常奇怪。

[
{
"name": "refs/heads/new-test-branch-from-api-call",
"newObjectId": "{{BranchObjectIdGoesHere}}",
"oldObjectId": "0000000000000000000000000000000000000000"
}
]

关于Azure DevOps API - 从 master 创建新分支而不添加更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70700296/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com