This tool is designed to help you manage your Azure DevOps pull requests (PRs) efficiently. It allows you to complete or abandon multiple PRs by providing their links through standard input (STDIN). This can be particularly useful when you have a large number of PRs to handle and want to automate the process.
- Complete multiple PRs with a single command
- Abandon multiple PRs with a single command
- Automatically squash and delete the source branch when completing PRs
To install this tool, you need to have Go installed on your machine. Follow these steps:
-
Clone the repository:
git clone [email protected]/cmdctl/prs.git cd prs
-
Build the executable:
go build -o prs
-
Move the executable to a directory in your PATH:
mv prs /usr/local/bin/
-
Configure azure cli to use default organization and project
az devops configure --defaults organization=https://dev.azure.com/contoso project=ContosoWebApp
The tool provides two main commands: complete
and abandon
. Each command requires a list of PR links provided through STDIN.
To complete PRs, use the complete
command. This command will:
- Mark the PR as completed
- Squash the commits [OPTIONAL] (use
--squash
flag) default isfalse
- Delete source branch [OPTIONAL] (use
--delete-source-branch
flag) default isfalse
-
Create a file
prs.txt
with the list of PR links, each on a new line:https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/123 https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/456
-
Run the command:
cat prs.txt | prs complete
or
prs complete < prs.txt
To abandon PRs, use the abandon
command. This command will mark the PR as abandoned.
-
Create a file
prs.txt
with the list of PR links, each on a new line:https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/123 https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/456
-
Run the command:
cat prs.txt | prs abandon
or
prs abandon < prs.txt
To display the help message, use the --help
or -h
flag:
prs --help
Outputs:
Usage:
prs [command] [options]
Commands:
complete Complete the specified pull requests
abandon Abandon the specified pull requests
Options:
--help, -h Show this help message and exit
Complete Command Options:
--delete-source-branch Delete the source branch after completing the pull request
--squash Squash the commits when completing the pull request
Abandon Command Options:
--delete-source-branch Delete the source branch after abandoning the pull request
The input should be a list of PR links, each on a new line. The tool will read these links from STDIN and process them accordingly. Make sure the links are in the following format:
https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/123
https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/456
You can include comments in your input file by prefixing the comment lines with --
. These lines will be ignored by the tool.
Create a file prs.txt
with PR links and comments:
-- This is a comment and will be ignored
https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/123
-- Another comment
https://dev.azure.com/yourorganization/yourproject/_git/yourrepo/pullrequest/456
If the tool encounters an error while processing a PR, it will print an error message and continue to the next PR. Make sure to check the output for any errors that may occur during the execution.
This project is licensed under the MIT License. See the LICENSE file for more details.