使用Azureureops上的api检查git分支是否被锁定

时间:2020-05-24 10:40:50

标签: git azure tfs branch devops

是否可以检查rest api或tf.exe或任何客户端库api锁定了哪个分支?

我尝试按照本文https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-5.0#gitref进行操作,并且响应中不包含锁定/未锁定标志。

谢谢。

2 个答案:

答案 0 :(得分:0)

您正在使用正确的Rest API。

GET https://{instance}/{collection}/{project}/_apis/git/repositories/{repositoryId}/refs?filter=heads/xxx &api-version=5.0 

请检查您的URI Parameters,只需确保使用正确的过滤器即可。

返回的json文件应该有 isLocked isLockedBy 信息。

答案 1 :(得分:0)

https://{baseUrl}/{organisation}/{project}/_apis/git/repositories/{repoId}/refs?filter=heads/***/master&api-version=6.0
  • 用正确的存储库详细信息替换占位符,并提供您要检查它是否已锁定的分支名称(heads/***/master)。

enter image description here

  • 这里有一个问题,如果你的分支没有被锁定,那么“Islocked”和“Creator”部分将永远不会得到响应。

  • 要获取所有分支信息,您可以在没有过滤器的情况下运行 url 例如。 https://{baseUrl}/{organisation}/{project}/_apis/git/repositories/{repoId}/refs?&api-version=6.0