Refs - Update Refs
建立、更新或刪除 refs(branch)。
更新 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 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
organization
|
path | True |
string |
Azure DevOps 組織的名稱。 |
|
repository
|
path | True |
string |
存放庫的名稱或標識碼。 |
|
project
|
path |
string |
項目識別碼或項目名稱 |
|
|
api-version
|
query | True |
string |
要使用的 API 版本。 這應該設定為 『7.1』 以使用此版本的 API。 |
|
project
|
query |
string |
小組專案的標識碼或名稱。 如果指定存放庫的標識碼,則為選擇性。 |
要求本文
| 名稱 | 類型 | Description |
|---|---|---|
| body |
要嘗試執行的 ref 更新清單 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
成功作業 |
安全性
oauth2
類型:
oauth2
Flow:
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
範圍
| 名稱 | Description |
|---|---|
| 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
}
定義
| 名稱 | Description |
|---|---|
|
Git |
|
|
Git |
|
|
Git |
TFS 伺服器的更新狀態。 |
GitRefUpdate
| 名稱 | 類型 | Description |
|---|---|---|
| isLocked |
boolean |
|
| name |
string |
|
| newObjectId |
string |
|
| oldObjectId |
string |
|
| repositoryId |
string (uuid) |
GitRefUpdateResult
| 名稱 | 類型 | Description |
|---|---|---|
| customMessage |
string |
結果物件的自定義訊息 例如,失敗的原因。 |
| isLocked |
boolean |
ref 是否已鎖定 |
| name |
string |
Ref 名稱 |
| newObjectId |
string |
新增物件標識碼 |
| oldObjectId |
string |
舊物件標識碼 |
| rejectedBy |
string |
拒絕更新之外掛程式的名稱。 |
| repositoryId |
string (uuid) |
存放庫標識碼 |
| success |
boolean |
如果 ref 更新成功,則為 True,否則為 false |
| updateStatus |
TFS 伺服器的更新狀態。 |
GitRefUpdateStatus
TFS 伺服器的更新狀態。
| 值 | Description |
|---|---|
| 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 更新要求,因為要求中顯示的舊物件標識碼不是資料庫嘗試更新時 ref 的物件識別碼。 最有可能的情況是呼叫端遺失了更新 ref 的競爭。 |
| succeeded |
指出 ref 更新要求已順利完成。 |
| succeededCorruptRef |
表示 ref 更新要求已順利完成,但傳入的 ref 已損毀,如同在 中,舊的對象標識碼不正確。 這應該只會在刪除期間發生。 |
| succeededNonExistentRef |
表示 ref 更新要求已順利完成,但 ref 實際上不存在,因此不會進行任何變更。 這應該只會在刪除期間發生。 |
| unprocessed |
未處理要求 |
| unresolvableToCommit |
無法完成 ref 更新要求,因為 ref 的新物件識別碼無法解析為認可物件(可能透過任意數目的標記) |
| writePermissionRequired |
無法完成 ref 更新要求,因為使用者缺少寫入此 ref 所需的寫入許可權 |