A command-line tool for submitting and updating GitHub Pull Requests from local Jujutsu commits that may be amended and rebased. Pull Requests can be stacked to allow for a series of code reviews of interdependent code.
Designed to be run as a Jujutsu subcommand: jj spr <command>
.
This project is a fork of the original spr tool, specifically building upon the Jujutsu integration work started by sunshowers.
This fork is a fork of a fork of spr which was then forked by sunshowers
.
This fork continues the sunshowers fork but tries to integrate fully with jujutsu rather than be based fully on git with a few jj parts.
git clone https://github.com/your-username/jj-spr.git
cd jj-spr
cargo install --path spr
This will install the jj-spr
binary to your ~/.cargo/bin
directory.
To use jj-spr
as a Jujutsu subcommand (enabling jj spr <command>
), add the following to your Jujutsu configuration:
# Add to your shell profile (.bashrc, .zshrc, etc.)
jj util exec --tool spr --name jj-spr
Add this to your Jujutsu config file (~/.jjconfig.toml
or .jj/repo/config.toml
):
[aliases]
spr = "util exec -- jj-spr"
If you prefer to configure the binary path directly:
[aliases]
spr = ["util", "exec", "--", "/path/to/jj-spr"]
After configuration, you can use commands like:
jj spr diff # Create/update a PR for the current change
jj spr diff -r @~1 # Create/update a PR for a specific change
jj spr land # Land (merge) a PR
jj spr list # List open PRs
-
Initialize in your repository:
cd your-jujutsu-repo jj spr init
-
Provide your GitHub Personal Access Token when prompted. This allows jj-spr to create and manage pull requests via the GitHub API.
-
Create a commit:
echo "new feature" > feature.txt jj commit -m "Add new feature"
-
Submit for review:
jj spr diff
-
Make changes and update:
echo "updated feature" > feature.txt jj describe -m "Add new feature (updated)" jj spr diff -m "Updated implementation"
-
Land the PR:
jj spr land
jj-spr excels at handling stacked PRs for related changes:
# Create first change
jj commit -m "Foundation change"
jj spr diff # Creates PR #1
# Create dependent change
jj commit -m "Building on foundation"
jj spr diff # Creates PR #2 stacked on PR #1
# Update just the second change
jj spr diff -r @ # Updates only PR #2
jj spr diff
- Create or update a pull request for the current changejj spr land
- Land (squash-merge) an approved pull requestjj spr list
- List open pull requests and their statusjj spr close
- Close a pull requestjj spr amend
- Update local commit message with content from GitHub
Most commands support revision selection:
jj spr diff -r @~1 # Specific revision
jj spr diff -r main..@ # Range of revisions (like --all)
jj spr diff -a --base trunk # All changes from trunk to current
For detailed help on any command:
jj spr help <command>
jj-spr stores configuration in your repository's git config:
# Set GitHub repository (if not auto-detected)
git config spr.githubRepository "owner/repo"
# Set branch prefix for generated branches
git config spr.branchPrefix "yourname/spr/"
# Require approval before landing
git config spr.requireApproval true
# Require test plan in commit messages
git config spr.requireTestPlan true
- Jujutsu: A working Jujutsu installation with a colocated Git repository
- GitHub Access: A GitHub Personal Access Token with appropriate permissions
- Git Repository: Your Jujutsu repository must be colocated with Git (
jj git init --colocate
)
- Change ID Handling: Works with Jujutsu's change IDs instead of Git commit hashes
- Commit Identity Preservation: Uses
jj describe
to maintain commit identity when updating messages - Native Jujutsu Commands: Integrates with
jj log
,jj commit
, and other Jujutsu operations
- Fixed Parent Immutability: Stacked changes no longer make parent commits immutable
- Proper Base Branches: Correctly creates base branches for stacked PRs
- Clean Diffs: GitHub shows only child changes, not cumulative diffs
- Per-Command Revisions:
jj spr diff -r <rev>
instead of global revision flags - Range Support:
jj spr diff -r main..@
automatically enables multi-commit mode - Better Defaults: Uses
@-
(parent of working copy) as the default revision
Contributions are welcome! Please:
- Check existing issues before starting work
- Add tests for new functionality
- Follow the existing code style (run
cargo fmt
andcargo clippy
) - Update documentation as needed
# Run unit tests
cargo test
# Run integration tests (requires jj and git)
cargo test --test '*'
# Check code quality
cargo clippy --all-features --all-targets
cargo fmt --check
This project is MIT licensed. See LICENSE for details.
- Original spr by the Cord team
- Jujutsu integration foundation by sunshowers
- Jujutsu project by martinvonz and contributors