Refs - Update Refs
创建、更新或删除 refs(分支)。
更新 ref 意味着使其指向与以前不同的提交。 必须同时指定旧提交和新提交以避免争用条件。
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=7.1
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?projectId={projectId}&api-version=7.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”才能使用此版本的 API。 |
|
project
|
query |
string |
团队项目的 ID 或名称。 如果指定存储库的 ID,则为可选。 |
请求正文
| 名称 | 类型 | 说明 |
|---|---|---|
| body |
要尝试执行的 ref 更新列表 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
成功作 |
安全性
oauth2
类型:
oauth2
流向:
accessCode
授权 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 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
作用域
| 名称 | 说明 |
|---|---|
| vso.code_write | 授予读取、更新和删除源代码、访问有关提交、更改集、分支和其他版本控制项目的元数据的能力。 此外,还授予创建和管理拉取请求和代码评审以及通过服务挂钩接收有关版本控制事件的通知的能力。 |
示例
Create/Update/Delete a ref by repositoryId
示例请求
POST https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/refs?api-version=7.1
[
{
"name": "refs/heads/vsts-api-sample/answer-woman-flame",
"oldObjectId": "0000000000000000000000000000000000000000",
"newObjectId": "ffe9cba521f00d7f60e322845072238635edb451"
}
]
示例响应
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 (uuid) |
GitRefUpdateResult
| 名称 | 类型 | 说明 |
|---|---|---|
| customMessage |
string |
结果对象的自定义消息,例如失败的原因。 |
| isLocked |
boolean |
ref 是否已锁定 |
| name |
string |
Ref 名称 |
| newObjectId |
string |
新建对象 ID |
| oldObjectId |
string |
旧对象 ID |
| rejectedBy |
string |
拒绝更新的插件的名称。 |
| repositoryId |
string (uuid) |
存储库 ID |
| success |
boolean |
如果 ref 更新成功,则为 True;否则为 false |
| updateStatus |
TFS 服务器的更新状态。 |
GitRefUpdateStatus
TFS 服务器的更新状态。
| 值 | 说明 |
|---|---|
| createBranchPermissionRequired |
无法完成 ref 更新请求,因为用户缺少创建分支的权限 |
| createTagPermissionRequired |
无法完成 ref 更新请求,因为用户缺少创建标记的权限 |
| forcePushRequired |
指示无法完成 ref 更新请求,因为图形的一部分会因此更改而断开连接,并且调用方对存储库没有 ForcePush 权限。 |
| invalidRefName |
指示无法完成 ref 更新请求,因为请求中显示的 ref 名称无效。 |
| locked |
无法完成 ref 更新,因为 ref 被其他用户锁定。 |
| manageNotePermissionRequired |
无法完成 ref 更新请求,因为用户缺少写入此注释所需的笔记创建权限 |
| refNameConflict |
无法完成 ref 更新,因为在不区分大小写的模式下,ref 名称与现有不同大小写的 ref 名称冲突。 |
| rejectedByPlugin |
无法完成 ref 更新,因为插件拒绝了更新。 |
| rejectedByPolicy |
无法完成 ref 更新,因为它被策略拒绝。 |
| staleOldObjectId |
指示无法完成 ref 更新请求,因为请求中显示的旧对象 ID 不是数据库尝试更新时 ref 的对象 ID。 最有可能的情况是调用方失去了更新 ref 的争用。 |
| succeeded |
指示 ref 更新请求已成功完成。 |
| succeededCorruptRef |
指示 ref 更新请求已成功完成,但传入的 ref 已损坏 ,如中所示,旧对象 ID 不正确。 这应仅在删除期间发生。 |
| succeededNonExistentRef |
指示 ref 更新请求已成功完成,但 ref 实际上不存在,因此没有进行更改。 这应仅在删除期间发生。 |
| unprocessed |
未处理请求 |
| unresolvableToCommit |
无法完成 ref 更新请求,因为无法将 ref 的新对象 ID 解析为提交对象(可能通过任意数量的标记) |
| writePermissionRequired |
无法完成 ref 更新请求,因为用户缺少写入此 ref 所需的写入权限 |