Mastodon

Working With Pull Requests in Azure DevOps

I like working at the terminal. No judgement if you don’t, but for me the terminal feels like a comfortable and productive place :-)

I also like to find ways to gradually improve my experience with the terminal, and a while back I mentioned to Lawrence that I’d created some git aliases to help me easily check out pull requests on github. He immediately replied pointing me to github.com/ldez/prm (Pull Request Manager) which is an awesome tool for checking out pull requests locally and working with them.

This is great for my workflow when I’m working with GitHub but I also spend time with repos on Azure DevOps. Fortunately, I discovered the azure-devops extenion for the Azure CLI.

Once installed and configured I can find and checkout PRs with az repos pr list and az repos pr checkout --id <id> as shown below.

~/source/MyTestRepo [master]
$ az repos pr list
ID    Created     Creator                     Title                                   Status    IsDraft    Repository
----  ----------  --------------------------  --------------------------------------  --------  ---------  ------------
5137  2020-01-16  stuart.leeks@example.com    Example PR to show az repos cli usage   Active    False      MyTestRepo
5139  2020-01-17  stuart.leeks@example.com    Another PR for demoing                  Active    False      MyTestRepo

~/source/MyTestRepo [master]
$ az repos pr checkout --id 5137  # Note the 5137 ID above

From vs-ssh.visualstudio.com:v3/example/SampleProject/MyTestRepo
 * branch            sl/example -> FETCH_HEAD
Branch 'sl/example' set up to track remote branch 'sl/example' from 'origin'.
Switched to a new branch 'sl/example'
From vs-ssh.visualstudio.com:v3/example/SampleProject/MyTestRepo
 * branch            sl/example -> FETCH_HEAD
Already up to date.

~/source/MyTestRepo [sl/example]
$