Spack Package PR Migration Tool
June 6, 2025 ยท View on GitHub
A command-line tool to copy open package pull requests from spack/spack to spack/spack-packages.
Requirements
gitghCLI tool (authenticated with GitHub)jqfor JSON processing- Current directory should be a clone of
spack/spack-packages
Installation Instructions
- Either use Spack to install the tool:
spack install migrate-package-prs spack load migrate-package-prs - Or, if you already have the
ghandjqutilities, you can simply clone the repository and add it to your PATH.git clone https://github.com/spack/migrate-package-prs.git export PATH="$PWD/migrate-package-prs/bin:$PATH"
Usage Instructions
-
Clone the new package repository and navigate to it:
git clone https://github.com/spack/spack-packages.git cd spack-packages -
Do a dry-run of the migration tool from within the
spack-packagesdirectory:migrate-pkg-prs -
If that looks good, run the tool with the
--migrateoption to create actual PRs:migrate-pkg-prs --migrate
Command Syntax
For advanced usage, you can specify options and PR numbers:
migrate-pkg-prs [OPTIONS] [PR_NUMBERS...]
Arguments
PR_NUMBERS- (Optional) Specific PR numbers to process
Options
--author USER- Process all open PRs for the specified GitHub user--migrate- Create PRs inspack/spack-packages(default: local branches only)-h, --help- Show help message
Behavior Rules
--authorandPR_NUMBERSare mutually exclusive- If
PR_NUMBERSare specified: process only those PRs - If
--authoris specified: process all open PRs for that user - If neither: process all open PRs for the currently authenticated GitHub user (default behavior)
Examples
Copy all open PRs for current GitHub user to local branches
migrate-pkg-prs
Copy and create PRs in spack/spack-packages
migrate-pkg-prs --migrate
Copy all open PRs for a specific user
migrate-pkg-prs --author johndoe
Copy specific PRs and create PRs in target repo
migrate-pkg-prs --migrate 12345 67890
Copy only a single PR to a local branch
migrate-pkg-prs 12345
How It Works
- Fetches the specified PR from
spack/spack - Cherry-picks commits (excluding merges) from the PR
- Creates a local branch named
spack-pr-{PR_NUMBER} - Optionally creates a new PR in
spack/spack-packageswith the--migrateflag
Branch Naming
Local branches are created with the format: spack-pr-{PR_NUMBER}
PR Migration
When using --migrate, the tool:
- Preserves the original PR title
- Adds a note to the PR body linking to the original PR
- Creates the PR against the
developbranch inspack/spack-packages
Error Handling
The tool handles various failure scenarios:
- Failed fetches
- Cherry-pick conflicts
- Non-package PRs
- Branch creation issues
- Authentication problems
Failed PRs are skipped and reported in the summary.
Authentication
Ensure you're authenticated with GitHub CLI:
gh auth login