1
votes

Is there a way to check which branch's are locked by rest api or tf.exe or any client library api?

I try work follow this article https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-5.0#gitref and the response not contains the locked/unlocked flag.

Thanks.

2
Hi David, Did you get a chance to implement the solution that I suggested? Were you able to resolve? If my reply helped or gave a right direction. Appreciate for marking it as an answer which will also help others in the community. - PatrickLu-MSFT

2 Answers

0
votes

You are using the right Rest API.

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

Kindly check your URI Parameters just make sure you are using the right filter.

There should be isLocked and isLockedBy info of returned json file.

0
votes
https://{baseUrl}/{organisation}/{project}/_apis/git/repositories/{repoId}/refs?filter=heads/***/master&api-version=6.0
  • Replace the placeholders with correct details of your repos and give your branch name(heads/***/master) of which you want check it is locked or not.

enter image description here

  • One catch over here, if your branch is not locked then "Islocked" & "Creator" section will not ever get in response.

  • To get for all the branches info you can run url without filters eg. https://{baseUrl}/{organisation}/{project}/_apis/git/repositories/{repoId}/refs?&api-version=6.0