Refs - Update Refs
创建、更新或删除引用 (分支) 。
更新 ref 意味着使其指向与过去不同的提交。 必须同时指定旧提交和新提交以避免争用条件。
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=7.1-preview.1
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?projectId={projectId}&api-version=7.1-preview.1
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
organization
|
path | True |
string |
Azure DevOps 组织的名称。 |
repository
|
path | True |
string |
存储库的名称或 ID。 |
project
|
path |
string |
项目 ID 或项目名称 |
|
api-version
|
query | True |
string |
要使用的 API 版本。 这应设置为“7.1-preview.1”才能使用此版本的 API。 |
project
|
query |
string |
团队项目的 ID 或名称。 如果指定存储库的 ID,则为可选。 |
请求正文
名称 | 类型 | 说明 |
---|---|---|
body |
要尝试执行的 ref 更新的列表 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功的操作 |
安全性
oauth2
Type:
oauth2
Flow:
accessCode
Authorization URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
Scopes
名称 | 说明 |
---|---|
vso.code_write | 授予读取、更新和删除源代码、访问有关提交、更改集、分支和其他版本控制项目元数据的能力。 此外,还授予创建和管理拉取请求和代码评审以及通过服务挂钩接收有关版本控制事件的通知的能力。 |
示例
Create/Update/Delete a ref by repositoryId
Sample Request
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/refs?api-version=7.1-preview.1
[
{
"name": "refs/heads/vsts-api-sample/answer-woman-flame",
"oldObjectId": "0000000000000000000000000000000000000000",
"newObjectId": "ffe9cba521f00d7f60e322845072238635edb451"
}
]
Sample Response
transfer-Encoding: chunked
{
"value": [
{
"repositoryId": "d3d1760b-311c-4175-a726-20dfc6a7f885",
"name": "refs/heads/vsts-api-sample/answer-woman-flame",
"oldObjectId": "0000000000000000000000000000000000000000",
"newObjectId": "ffe9cba521f00d7f60e322845072238635edb451",
"isLocked": false,
"updateStatus": "succeeded",
"success": true
}
],
"count": 1
}
定义
名称 | 说明 |
---|---|
Git |
|
Git |
|
Git |
TFS 服务器中的更新状态。 |
GitRefUpdate
名称 | 类型 | 说明 |
---|---|---|
isLocked |
boolean |
|
name |
string |
|
newObjectId |
string |
|
oldObjectId |
string |
|
repositoryId |
string |
GitRefUpdateResult
名称 | 类型 | 说明 |
---|---|---|
customMessage |
string |
结果对象的自定义消息 例如,失败的原因。 |
isLocked |
boolean |
引用是否已锁定 |
name |
string |
引用名称 |
newObjectId |
string |
新对象 ID |
oldObjectId |
string |
旧对象 ID |
rejectedBy |
string |
拒绝更新的插件的名称。 |
repositoryId |
string |
仓库 ID |
success |
boolean |
如果 ref 更新成功,则为 True;否则为 false |
updateStatus |
TFS 服务器中的更新状态。 |
GitRefUpdateStatus
TFS 服务器中的更新状态。
名称 | 类型 | 说明 |
---|---|---|
createBranchPermissionRequired |
string |
无法完成 ref 更新请求,因为用户缺少创建分支的权限 |
createTagPermissionRequired |
string |
无法完成 ref 更新请求,因为用户缺少创建标记的权限 |
forcePushRequired |
string |
指示无法完成 ref 更新请求,因为此更改将断开图形的一部分,并且调用方对存储库没有 ForcePush 权限。 |
invalidRefName |
string |
指示无法完成 ref 更新请求,因为请求中提供的引用名称无效。 |
locked |
string |
无法完成 ref 更新,因为 ref 被另一个用户锁定。 |
manageNotePermissionRequired |
string |
无法完成 ref 更新请求,因为用户缺少写入此笔记所需的笔记创建权限 |
refNameConflict |
string |
无法完成 ref 更新,因为在不区分大小写的模式下,ref 名称与现有的大小写不同的 ref 名称冲突。 |
rejectedByPlugin |
string |
无法完成 ref 更新,因为插件拒绝了该更新。 |
rejectedByPolicy |
string |
无法完成 ref 更新,因为策略拒绝了该更新。 |
staleOldObjectId |
string |
指示无法完成 ref 更新请求,因为在数据库尝试更新时,请求中显示的旧对象 ID 不是 ref 的对象 ID。 最有可能的情况是调用方失去了更新 ref 的争用。 |
succeeded |
string |
指示 ref 更新请求已成功完成。 |
succeededCorruptRef |
string |
指示 ref 更新请求已成功完成,但传入的 ref 已损坏 - 与中一样,旧对象 ID 错误。 这应该仅在删除期间发生。 |
succeededNonExistentRef |
string |
指示 ref 更新请求已成功完成,但 ref 实际上不存在,因此未进行任何更改。 这应该仅在删除期间发生。 |
unprocessed |
string |
未处理请求 |
unresolvableToCommit |
string |
无法完成 ref 更新请求,因为 ref 的新对象 ID 无法解析为提交对象, (可能通过任意数量的标记) |
writePermissionRequired |
string |
无法完成 ref 更新请求,因为用户缺少写入此 ref 所需的写入权限 |