Refs - Update Ref

锁定或解锁分支。

PATCH https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?filter={filter}&api-version=5.0
PATCH https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?filter={filter}&projectId={projectId}&api-version=5.0

URI 参数

名称 必需 类型 说明
organization
path True

string

Azure DevOps 组织的名称。

repositoryId
path True

string

存储库的名称或 ID。

project
path

string

项目 ID 或项目名称

api-version
query True

string

要使用的 API 版本。 应将其设置为“5.0”才能使用此版本的 API。

filter
query True

string

要锁定/解锁的分支的名称

projectId
query

string

团队项目的 ID 或名称。 如果指定存储库的 ID,则为可选。

请求正文

名称 类型 说明
isLocked

boolean

name

string

newObjectId

string

oldObjectId

string

repositoryId

string

响应

名称 类型 说明
200 OK

GitRef

成功的操作

安全性

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 授予读取、更新和删除源代码、访问有关提交、更改集、分支和其他版本控制项目的元数据的能力。 此外,还授予创建和管理拉取请求和代码评审以及通过服务挂钩接收有关版本控制事件的通知的能力。

示例

Lock/unlock branch

Sample Request

PATCH https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/refs?filter=heads/master&api-version=5.0

{
  "isLocked": true
}

Sample Response

{
  "name": "refs/heads/master",
  "objectId": "ffe9cba521f00d7f60e322845072238635edb451",
  "isLockedBy": {
    "displayName": "Normal Paulk",
    "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/ac5aaba6-a66a-4e1d-b508-b060ec624fa9",
    "_links": {
      "avatar": {
        "href": "https://dev.azure.com/fabrikam/_apis/GraphProfile/MemberAvatars/aad.YmFjMGYyZDctNDA3ZC03OGRhLTlhMjUtNmJhZjUwMWFjY2U5"
      }
    },
    "id": "ac5aaba6-a66a-4e1d-b508-b060ec624fa9",
    "uniqueName": "dev@mailserver.com",
    "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=ac5aaba6-a66a-4e1d-b508-b060ec624fa9",
    "descriptor": "aad.YmFjMGYyZDctNDA3ZC03OGRhLTlhMjUtNmJhZjUwMWFjY2U5"
  },
  "isLocked": true,
  "creator": {
    "displayName": "Normal Paulk",
    "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/ac5aaba6-a66a-4e1d-b508-b060ec624fa9",
    "_links": {
      "avatar": {
        "href": "https://dev.azure.com/fabrikam/_apis/GraphProfile/MemberAvatars/aad.YmFjMGYyZDctNDA3ZC03OGRhLTlhMjUtNmJhZjUwMWFjY2U5"
      }
    },
    "id": "ac5aaba6-a66a-4e1d-b508-b060ec624fa9",
    "uniqueName": "dev@mailserver.com",
    "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=ac5aaba6-a66a-4e1d-b508-b060ec624fa9",
    "descriptor": "aad.YmFjMGYyZDctNDA3ZC03OGRhLTlhMjUtNmJhZjUwMWFjY2U5"
  },
  "url": "https://dev.azure.com/fabrikam/7484f783-66a3-4f27-b7cd-6b08b0b077ed/_apis/git/repositories/d3d1760b-311c-4175-a726-20dfc6a7f885/refs?filter=heads%2Fmaster"
}

定义

名称 说明
GitRef
GitRefUpdate
GitStatus

此类包含发布状态的服务/扩展的元数据。

GitStatusContext

唯一标识状态的状态上下文。

GitStatusState

状态的状态。

IdentityRef
ReferenceLinks

表示 REST 引用链接集合的类。

GitRef

名称 类型 说明
_links

ReferenceLinks

表示 REST 引用链接集合的类。

creator

IdentityRef

isLocked

boolean

isLockedBy

IdentityRef

name

string

objectId

string

peeledObjectId

string

statuses

GitStatus[]

此类包含发布状态的服务/扩展的元数据。

url

string

GitRefUpdate

名称 类型 说明
isLocked

boolean

name

string

newObjectId

string

oldObjectId

string

repositoryId

string

GitStatus

此类包含发布状态的服务/扩展的元数据。

名称 类型 说明
_links

ReferenceLinks

参考链接。

context

GitStatusContext

状态的上下文。

createdBy

IdentityRef

创建状态的标识。

creationDate

string

状态的创建日期和时间。

description

string

状态说明。 通常描述状态的当前状态。

id

integer

状态标识符。

state

GitStatusState

状态的状态。

targetUrl

string

包含状态详细信息的 URL。

updatedDate

string

状态的上次更新日期和时间。

GitStatusContext

唯一标识状态的状态上下文。

名称 类型 说明
genre

string

状态的流派。 生成状态的服务/工具的名称通常可以为空。

name

string

状态的名称标识符不能为 null 或空。

GitStatusState

状态的状态。

名称 类型 说明
error

string

出现错误的状态。

failed

string

状态失败。

notApplicable

string

状态不适用于目标对象。

notSet

string

未设置状态。 默认状态。

pending

string

状态挂起。

succeeded

string

状态成功。

IdentityRef

名称 类型 说明
_links

ReferenceLinks

此字段包含有关图形主题的零个或多个相关链接。 可以调用这些链接来获取有关此图主题的其他关系或更多详细信息。

descriptor

string

描述符是在系统运行时引用图形主题的主要方式。 此字段将唯一标识帐户和组织中的同一图形主题。

directoryAlias

string

displayName

string

这是图形主题的非唯一显示名称。 若要更改此字段,必须在源提供程序中更改其值。

id

string

imageUrl

string

inactive

boolean

isAadIdentity

boolean

isContainer

boolean

isDeletedInOrigin

boolean

profileUrl

string

uniqueName

string

url

string

此 URL 是此图主题的源资源的完整路由。

表示 REST 引用链接集合的类。

名称 类型 说明
links

object

链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读。