Azure DevOps pull request tags (labels): adding and removing them, the shared tag pool, and the REST API
A tag on a pull request is a short word, such as WIP, hotfix or Bug, that tells reviewers what state the change is in or what it is for. The web page calls them tags; the REST API and Visual Studio call the same thing labels. Below is how they work, from Microsoft's Create a pull request (Add tags to a pull request), View, filter, and open pull requests and the REST reference for Pull Request Labels.
Adding and removing tags on the web page
- When creating: on the New pull request page, type a tag name in the Tags section.
- Afterwards: manage them in the Tags section of the pull request's Overview.
- Tags show on the pull request and in the pull request list.
- Removing a tag from a pull request leaves the tag name itself: other pull requests and work items that have it keep it.
One pool of tag names with work items
- Pull request tag names and work item tag names share one pool in an organization (on Azure DevOps Server, a project collection).
- The combined limit is 150,000 unique tag names. A tag typed on a pull request that no pull request or work item has used yet becomes a new name in that pool.
Finding pull requests by tag
- The pull request list in Visual Studio 2022 (Git > your Git service > View Pull Requests) filters by author, label and other attributes.
az repos pr listhas no parameter for tags: it filters by creator, reviewer, source branch, target branch, status, repository and project.
The REST API
GET …/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/labels?api-version=7.1lists the tags of a pull request.POSTon the same address with{"name": "hotfix"}creates the tag if it does not exist yet and adds it to the pull request. The name is the only field; the answer is the tag definition, with itsid,nameandactive.DELETE …/labels/{labelIdOrName}removes a tag from the pull request, by its name or id; the tag itself is not deleted.- The token needs Code (Read & write) to add and remove. Microsoft's reference says users with read permission in the repository can add, get and delete labels.
- The resource was released in REST 7.0 (Azure DevOps Server 2022). Older servers have it as a preview, back to 4.1 (TFS 2018 Update 2): ask it with
api-version=6.0-preview.1,5.0-preview.1and so on.
Tags in IntelliJ IDEA
Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, lists the pull requests of Azure DevOps Services and Azure DevOps Server in an IDE tool window. From version 1.0.62 each row shows the pull request's tags after its branches, and the Overview shows them above the description. Edit tags (Pro) opens one box with the tags separated by commas: type a name to add it, delete one to remove it. Names are compared ignoring case, and only what changed is sent. The review inbox and the tags shown are free; voting, commenting, editing tags, adding reviewers, completing and creating pull requests are Pro, with a 30-day trial.
Get it on JetBrains Marketplace
Azure DevOps and Visual Studio are trademarks of Microsoft Corporation; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.
More: work items linked to a pull request · draft pull requests · status checks · required reviewers and path filters · 日本語