devops-pr-cli
v1.0.1
Published
CLI tool for creating and managing Azure DevOps pull requests
Downloads
10
Maintainers
Readme
devops-pr-cli
CLI tool for creating and managing Azure DevOps pull requests from the command line.
Features
- 🚀 Create pull requests from current branch
- 📋 List and filter pull requests
- 🔍 View detailed PR information
- 🔄 Checkout PR branches locally
- 🎯 Auto-detect repository information from git (org/project/repo)
- 🌐 One config works across all projects in your organization
- 💬 Interactive prompts for easy usage
- 🔐 Secure PAT token authentication
- 🎨 Beautiful terminal output
Installation
From npm (Recommended)
npm install -g devops-pr-cliFrom Source
For development or contributing:
git clone https://github.com/qushuangru/devops-pr-cli.git
cd devops-pr-cli
npm install
npm run build
npm linkQuick Start
1. Configure
Run the configuration wizard on first use:
devops-pr config initYou'll be prompted to enter:
- Azure DevOps server URL (e.g.,
https://dev.azure.comor your on-premise server) - Personal Access Token (PAT)
- Default target branch (e.g.,
mainormaster)
Note: Organization, project, and repository are automatically detected from your git remote URL. No need to configure them manually!
Configuration is saved to ~/.devops-pr-cli/config.json
2. Create a Pull Request
Navigate to your git repository and run:
devops-pr pr createYou'll be prompted to enter:
- PR title
- PR description (opens your default editor)
Or provide details via flags:
devops-pr pr create --title "[feat] Add new feature" --description "This PR adds..." --target master3. List Pull Requests
# List active PRs (default)
devops-pr pr list
# List all PRs
devops-pr pr list --state all
# List completed PRs
devops-pr pr list --state completed
# Limit results
devops-pr pr list --limit 104. View PR Details
devops-pr pr view 1112446
# Include comments
devops-pr pr view 1112446 --comments
# JSON output
devops-pr pr view 1112446 --json5. Checkout PR Branch
devops-pr pr checkout 1112446Commands
Configuration Commands
# Initialize configuration (interactive wizard)
devops-pr config init
# View current configuration
devops-pr config viewPull Request Commands
# Create a pull request
devops-pr pr create [options]
Options:
-t, --title <title> Pull request title
-d, --description <desc> Pull request description
-b, --target <branch> Target branch (default: from config)
--draft Create as draft PR
# List pull requests
devops-pr pr list [options]
Options:
-s, --state <state> Filter by state: active|completed|abandoned|all (default: active)
-l, --limit <number> Maximum number of PRs to show (default: 20)
--target <branch> Filter by target branch
# View pull request details
devops-pr pr view <pr-id> [options]
Options:
--comments Include comments
--json Output as JSON
# Checkout pull request branch
devops-pr pr checkout <pr-id>Personal Access Token (PAT)
To use this tool, you need a Personal Access Token with the following permissions:
- Code: Read
- Pull Requests: Read & Write
Creating a PAT
- Go to your Azure DevOps profile settings
- Navigate to Personal Access Tokens
- Click New Token
- Select the required permissions
- Copy the generated token
- Use it during
devops-pr config init
Example URL: https://dev.azure.com/{your-organization}/_usersSettings/tokens
Examples
Typical Workflow
# 1. Create a feature branch and make changes
git checkout -b feature/my-new-feature
# ... make changes ...
git add .
git commit -m "feat: Add new feature"
git push -u origin feature/my-new-feature
# 2. Create a pull request
devops-pr pr create
# 3. Check PR status
devops-pr pr list
# 4. View your PR
devops-pr pr view <pr-id>Review Someone's PR
# 1. List active PRs
devops-pr pr list
# 2. View PR details
devops-pr pr view 1112446
# 3. Checkout PR for local testing
devops-pr pr checkout 1112446
# 4. Test the changes
npm test
# 5. Leave feedback in Azure DevOps web UITroubleshooting
Configuration not found
❌ Error: Configuration not found. Please run "devops-pr config init" to set up.Solution: Run devops-pr config init to configure the tool.
Authentication failed
❌ Error: Authentication failed. Your PAT token may be invalid or expired.Solutions:
- Verify your PAT token hasn't expired
- Ensure the token has required permissions
- Run
devops-pr config initto reconfigure
Not in a git repository
❌ Error: Not in a git repository. Please navigate to a git repository.Solution: Navigate to a directory that contains a git repository.
No origin remote found
❌ Error: No origin remote found. Please add a remote: git remote add origin <url>Solution: Add an origin remote pointing to your Azure DevOps repository.
Upgrading
To update to the latest version:
npm update -g devops-pr-cliNote: If you're upgrading from an older version, you may want to reinitialize your config to remove deprecated fields:
devops-pr config initThe new config wizard only asks for server URL, PAT token, and default branch (organization/project are now auto-detected).
Requirements
- Node.js >= 16.0.0
- Git installed and configured
- Azure DevOps Personal Access Token
Development
Setup
git clone https://github.com/qushuangru/devops-pr-cli.git
cd devops-pr-cli
npm installBuild
npm run buildRun in Development
npm run dev -- pr listLink for Local Testing
npm link
devops-pr config initLicense
MIT
Author
Shuangru Qu
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
