### Typical Stack PR Workflow Example Source: https://context7.com/modular/stack-pr/llms.txt Demonstrates a complete end-to-end stacked PR workflow, from initial setup and commit creation to previewing, submitting, amending, rebasing, and landing PRs. ```bash # 1. Start from an updated main branch git checkout main git pull origin main ``` ```bash # 2. Create a feature branch git checkout -b add-user-auth ``` ```bash # 3. Make changes in logical commits (each becomes a PR) # First commit: Add user model git add src/models/user.py git commit -m "Add user model with validation" ``` ```bash # Second commit: Add authentication service git add src/services/auth.py git commit -m "Add authentication service" ``` ```bash # Third commit: Add API endpoints git add src/api/auth_routes.py git commit -m "Add authentication API endpoints" ``` ```bash # 4. Preview the stack before submitting stack-pr view ``` ```bash # 5. Create the stack of PRs (with reviewers and first PR as non-draft) stack-pr submit --reviewer="senior-dev" --draft-bitmask 011 ``` ```bash # 6. After review feedback, amend commits and resubmit git rebase -i HEAD~3 # Edit commits as needed stack-pr submit ``` ```bash # 7. Rebase on latest main when needed git pull origin main git rebase main stack-pr submit ``` ```bash # 8. Land PRs one by one after approval stack-pr land # Lands first PR, rebases remaining stack-pr land # Lands second PR, rebases remaining stack-pr land # Lands final PR ``` ```bash # Or abandon if the feature is cancelled stack-pr abandon ``` -------------------------------- ### Install and Authenticate GitHub CLI Source: https://context7.com/modular/stack-pr/llms.txt Ensure the GitHub CLI is installed and authenticated before using Stack PR. This example shows installation on macOS and authentication steps. ```bash # Install GitHub CLI (macOS) brew install gh ``` ```bash # Authenticate with SSH gh auth login ``` ```bash # Verify authentication gh auth status ``` -------------------------------- ### Example stack-pr configuration file Source: https://github.com/modular/stack-pr/blob/main/README.md An example of a configuration file (.stack-pr.cfg) showing default values for various settings. ```cfg [common] verbose=True hyperlinks=True draft=False keep_body=False stash=False show_tips=True [repo] remote=origin target=main reviewer=GithubHandle1,GithubHandle2 branch_name_template=$USERNAME/$BRANCH [land] style=bottom-only ``` -------------------------------- ### Install stack-pr with pipx Source: https://github.com/modular/stack-pr/blob/main/README.md Use pipx to install the stack-pr tool. Ensure pipx is installed and configured. ```bash pipx install stack-pr ``` -------------------------------- ### Install Stack PR using pipx Source: https://context7.com/modular/stack-pr/llms.txt Install the Stack PR tool using pipx for isolated package management. Alternatively, install from source by cloning the repository and using pipx. ```bash # Install via pipx (recommended) pipx install stack-pr ``` ```bash # Or install from source git clone https://github.com/modular/stack-pr.git cd stack-pr pipx install . ``` -------------------------------- ### Stack-PR Configuration File Example Source: https://context7.com/modular/stack-pr/llms.txt Create a .stack-pr.cfg file in your repository root to set default values for all options. This file uses an INI format for configuration. ```ini # .stack-pr.cfg - Example configuration file [common] verbose=True hyperlinks=True draft=False keep_body=False stash=False show_tips=True [repo] remote=origin target=main reviewer=alice,bob branch_name_template=$USERNAME/$BRANCH [land] style=bottom-only ``` -------------------------------- ### Install stack-pr from source with pipx Source: https://github.com/modular/stack-pr/blob/main/README.md Manually install the stack-pr tool from its source code using pipx. This is useful for development or when the latest changes are needed. ```bash pipx install . ``` -------------------------------- ### Configure stack-pr settings Source: https://context7.com/modular/stack-pr/llms.txt Set configuration values in the .stack-pr.cfg file to customize default behavior for the repository. Examples include enabling verbose mode, disabling usage tips, setting draft mode, defining target branches, and specifying default reviewers. ```bash # Set verbose mode stack-pr config common.verbose=True ``` ```bash # Disable usage tips after commands stack-pr config common.show_tips=False ``` ```bash # Set draft mode as default stack-pr config common.draft=True ``` ```bash # Set the remote target branch (useful for repos using 'master') stack-pr config repo.target=master ``` ```bash # Set default reviewers stack-pr config repo.reviewer=alice,bob ``` ```bash # Set custom branch name template stack-pr config repo.branch_name_template='$USERNAME/$BRANCH' ``` ```bash # Disable the land command (require GitHub web UI for merging) stack-pr config land.style=disable ``` -------------------------------- ### Create a feature branch Source: https://github.com/modular/stack-pr/blob/main/README.md Start a new feature branch from the main branch to begin your work. This ensures your changes are isolated. ```bash git checkout main git pull git checkout -b my-feature ``` -------------------------------- ### Stack-PR Common Arguments Source: https://context7.com/modular/stack-pr/llms.txt Control branch references and output behavior using common arguments supported by all subcommands. Examples include specifying remote names, local base/head branches, remote target branches, and enabling verbose output. ```bash # Specify remote name (default: origin) stack-pr submit -R upstream ``` ```bash # Specify local base branch stack-pr submit -B feature-base ``` ```bash # Specify local head branch (default: HEAD) stack-pr submit -H my-feature ``` ```bash # Specify remote target branch (default: main) stack-pr submit -T develop ``` ```bash # Enable verbose output from Git commands stack-pr submit -V ``` ```bash # Disable hyperlinks in terminal output stack-pr submit --no-hyperlinks ``` ```bash # Custom branch name template with variables # $USERNAME: GitHub username # $BRANCH: Current branch name # $ID: Branch number in the stack stack-pr submit --branch-name-template='$USERNAME/stack/$ID' ``` -------------------------------- ### Configure stack-pr settings Source: https://github.com/modular/stack-pr/blob/main/README.md Use the config command to set configuration values in the .stack-pr.cfg file. This command creates or updates settings. ```bash stack-pr config common.verbose=True ``` ```bash stack-pr config common.show_tips=False ``` ```bash stack-pr config repo.target=master ``` ```bash stack-pr config repo.reviewer=user1,user2 ``` ```bash stack-pr config repo.branch_name_template=$USERNAME/stack ``` ```bash stack-pr config land.style=disable ``` ```bash stack-pr config land.style=bottom-only ``` -------------------------------- ### Typical stack-pr Workflow Source: https://github.com/modular/stack-pr/blob/main/README.md This workflow outlines the iterative process of making local changes, submitting them as a stack of PRs, and eventually merging them. ```bash while not ready to merge: make local changes commit to local git repo or amend existing commits create or update the stack with `stack-pr.py submit` merge changes with `stack-pr.py land` ``` -------------------------------- ### View the PR stack Source: https://github.com/modular/stack-pr/blob/main/README.md Safely preview the current state of your stacked PRs before submitting. This command helps identify potential issues early in the process. ```bash stack-pr view ``` -------------------------------- ### Inspect and Land PRs with Custom Ranges Source: https://github.com/modular/stack-pr/blob/main/README.md Combine `view` and `land` commands with custom ranges to inspect and manage specific parts of your commit stack. This is useful for landing a subset of PRs or for complex branching strategies. ```bash # Inspect what commits will be included HEAD~5..HEAD stack-pr view -B HEAD~5 ``` ```bash # Create a stack from last five commits stack-pr submit -B HEAD~5 ``` ```bash # Inspect what commits will be included into the range HEAD~5..HEAD~2 stack-pr view -B HEAD~5 -H HEAD~2 ``` ```bash # Land first three PRs from the stack stack-pr land -B HEAD~5 -H HEAD~2 ``` -------------------------------- ### Submit Stack PRs with Reviewers Source: https://github.com/modular/stack-pr/blob/main/README.md Use the `--reviewer` option with `stack-pr submit` to assign specified reviewers to the created PRs. ```bash # stack-pr submit --reviewer="handle1,handle2" ``` -------------------------------- ### View Stacked Pull Requests Source: https://github.com/modular/stack-pr/blob/main/README.md Use the `view` command to see the current stack of pull requests. This helps in understanding the order and status of your stacked PRs before making changes. ```python # stack-pr view VIEW **Stack:** * cc932b71 (#439, 'ZolotukhinM/stack/103' -> 'ZolotukhinM/stack/102'): Optimized navigation algorithms for deep space travel * 3475c898 (#438, 'ZolotukhinM/stack/102' -> 'ZolotukhinM/stack/101'): Fixed zero-gravity coffee spill bug in beverage dispenser * 99c4cd9a (#437, 'ZolotukhinM/stack/101' -> 'main'): Added warp drive functionality to spaceship engine. SUCCESS! ``` ```python # stack-pr view VIEW **Stack:** * 8177f347 (#439, 'ZolotukhinM/stack/103' -> 'ZolotukhinM/stack/102'): Optimized navigation algorithms for deep space travel * 35c429c8 (#438, 'ZolotukhinM/stack/102' -> 'main'): Fixed zero-gravity coffee spill bug in beverage dispenser ``` -------------------------------- ### Submit Stack PRs with Draft Option Source: https://github.com/modular/stack-pr/blob/main/README.md Use the `--draft` option with `stack-pr submit` to mark all created PRs as drafts, which can help avoid over-burdening CI during development. ```bash # stack-pr submit --draft ``` -------------------------------- ### Configure Stack PR via Environment Variables Source: https://context7.com/modular/stack-pr/llms.txt Configure Stack PR behavior through environment variables. This is particularly useful for CI/CD pipelines or setting temporary configurations. ```bash # Set custom config file path export STACKPR_CONFIG=/path/to/custom-config.cfg ``` ```bash # Set default reviewer via environment variable export STACK_PR_DEFAULT_REVIEWER="alice,bob,charlie" ``` ```bash # Use in CI/CD pipelines STACK_PR_DEFAULT_REVIEWER="ci-bot" stack-pr submit --draft ``` -------------------------------- ### View Commits for Stack PR Source: https://github.com/modular/stack-pr/blob/main/README.md Use the `view` command to inspect commits that will be included in the PR stack. This is a safe command that does not modify any changes. ```bash # stack-pr view ... VIEW **Stack:** * **cc932b71** (No PR): Optimized navigation algorithms for deep space travel * **3475c898** (No PR): Fixed zero-gravity coffee spill bug in beverage dispenser * **99c4cd9a** (No PR): Added warp drive functionality to spaceship engine. SUCCESS! ``` -------------------------------- ### Submit the PR stack Source: https://github.com/modular/stack-pr/blob/main/README.md Create or update the stack of GitHub pull requests based on your commits. This is the primary command for pushing your stacked changes. ```bash stack-pr submit ``` -------------------------------- ### Submit Stack PRs with Draft Bitmask Source: https://github.com/modular/stack-pr/blob/main/README.md Use the `--draft-bitmask` option to selectively mark PRs as drafts within a stack. The bitmask length must match the number of stacked PRs, where '1' indicates draft and '0' indicates non-draft. This option is overridden by `--draft`. ```bash # stack-pr submit --draft-bitmask 0010 ``` -------------------------------- ### Submit Stack PRs Source: https://github.com/modular/stack-pr/blob/main/README.md Use the `submit` command to create or update a stack of pull requests for the specified commits. This command pushes changes to remote branches and updates corresponding PRs. ```bash # stack-pr submit ... SUCCESS! ``` -------------------------------- ### Submit Stack PRs Source: https://context7.com/modular/stack-pr/llms.txt Create or update a stack of pull requests from local commits. This command pushes changes and creates/updates associated PRs. Options include draft mode, reviewer assignment, stashing changes, and specifying base/head commits. ```bash # Basic usage: create PRs for all commits since main git checkout main && git pull git checkout -b my-feature # Make changes and commit git commit -m "First change" git commit -m "Second change" git commit -m "Third change" # Create the stack of PRs stack-pr submit ``` ```bash # Submit with draft mode for all PRs stack-pr submit --draft ``` ```bash # Submit with specific PRs as drafts using bitmask (1=draft, 0=non-draft) # This makes the second PR a draft in a stack of three stack-pr submit --draft-bitmask 010 ``` ```bash # Assign reviewers when creating PRs stack-pr submit --reviewer="alice,bob" ``` ```bash # Stash uncommitted changes before submitting stack-pr submit --stash ``` ```bash # Keep existing PR body content, only update cross-links stack-pr submit --keep-body ``` ```bash # Submit only the last 3 commits stack-pr submit -B HEAD~3 ``` ```bash # Submit using origin/main as the base reference stack-pr submit -B origin/main ``` -------------------------------- ### Create commits for PRs Source: https://github.com/modular/stack-pr/blob/main/README.md Make changes and create separate commits, with each commit intended for a distinct pull request in the stack. This organizes your work for stacked PRs. ```bash # Make some changes git commit -m "First change" # Make more changes git commit -m "Second change" # And so on... ``` -------------------------------- ### Rebase PR stack on latest main Source: https://github.com/modular/stack-pr/blob/main/README.md Update your feature branch with the latest changes from the main branch and rebase your commits. This ensures your stack is up-to-date before resubmitting. ```bash git checkout my-feature git pull origin main # Get the latest main git rebase main # Rebase your commits on top of main stack-pr submit # Resubmit to update all PRs ``` -------------------------------- ### Land the bottom-most PR Source: https://github.com/modular/stack-pr/blob/main/README.md Merge the lowest PR in your stack and automatically rebase the remaining PRs. This command simplifies the process of merging stacked PRs sequentially. ```bash stack-pr land ``` -------------------------------- ### Land Stacked Pull Requests Source: https://github.com/modular/stack-pr/blob/main/README.md The `land` command merges the first pull request in the stack into the target branch and rebases the remaining PRs. This process is repeated until all PRs in the stack are landed. ```python # stack-pr land LAND Stack: * cc932b71 (#439, 'ZolotukhinM/stack/103' -> 'ZolotukhinM/stack/102'): Optimized navigation algorithms for deep space travel * 3475c898 (#438, 'ZolotukhinM/stack/102' -> 'ZolotukhinM/stack/101'): Fixed zero-gravity coffee spill bug in beverage dispenser * 99c4cd9a (#437, 'ZolotukhinM/stack/101' -> 'main'): Added warp drive functionality to spaceship engine. Landing 99c4cd9a (#437, 'ZolotukhinM/stack/101' -> 'main'): Added warp drive functionality to spaceship engine. ...Rebasing 3475c898 (#438, 'ZolotukhinM/stack/102' -> 'ZolotukhinM/stack/101'): Fixed zero-gravity coffee spill bug in beverage dispenser ...Rebasing cc932b71 (#439, 'ZolotukhinM/stack/103' -> 'ZolotukhinM/stack/102'): Optimized navigation algorithms for deep space travel ...SUCCESS! ``` -------------------------------- ### Helper Alias for Git History Source: https://github.com/modular/stack-pr/blob/main/README.md A convenient bash alias to display commit history in a concise format, showing commits from the merge base of origin/main up to HEAD. ```bash alias githist='git log --abbrev-commit --oneline $(git merge-base origin/main HEAD)^..HEAD' ``` -------------------------------- ### View Stack PRs Source: https://context7.com/modular/stack-pr/llms.txt Inspect the current stack of pull requests without making any changes. This command can be used to understand the state of your stack, including submitted and unsubmitted PRs. It supports viewing specific ranges of commits. ```bash # View the current stack state stack-pr view ``` ```bash # View a specific range of commits stack-pr view -B HEAD~5 ``` ```bash # View commits excluding the last two stack-pr view -H HEAD~2 ``` ```bash # Combine base and head options stack-pr view -B HEAD~5 -H HEAD~2 ``` -------------------------------- ### Land Stack PRs Source: https://context7.com/modular/stack-pr/llms.txt Merge the bottom-most pull request in the stack and automatically rebase the remaining PRs. This ensures proper sequential merging of stacked changes. You can also land multiple PRs by specifying a head range. ```bash # Land the first PR in the stack stack-pr land ``` ```bash # Land multiple PRs by specifying head stack-pr land -B HEAD~5 -H HEAD~2 ``` -------------------------------- ### Abandon a range of commits Source: https://context7.com/modular/stack-pr/llms.txt Use this command to abandon a specific range of commits within your stack. ```bash stack-pr abandon -B HEAD~3 ``` -------------------------------- ### Submit Stacked Pull Requests with Custom Ranges Source: https://github.com/modular/stack-pr/blob/main/README.md Use `stack-pr submit` with custom base (`-B`) and head (`-H`) branches to define the range of commits for the stack. This allows for more control over which commits are included in the PR stack. ```bash # Submit a stack of last 5 commits stack-pr submit -B HEAD~5 ``` ```bash # Use 'origin/main' instead of 'main' as the base for the stack stack-pr submit -B origin/main ``` ```bash # Do not include last two commits to the stack stack-pr submit -H HEAD~2 ``` -------------------------------- ### Update stack after GitHub merge Source: https://github.com/modular/stack-pr/blob/main/README.md After merging the bottom-most PR via the GitHub UI, update your local branch with the latest changes and resubmit the stack. This rebases the remaining PRs. ```bash git checkout my-feature git pull origin main # Get the merged changes stack-pr submit # Resubmit the stack to rebase remaining PRs ``` -------------------------------- ### Abandon Stack PRs Source: https://context7.com/modular/stack-pr/llms.txt Remove all stack metadata from commits, delete corresponding branches, and close associated pull requests. Use this command to clean up a stack that is no longer needed. ```bash # Abandon the entire stack stack-pr abandon ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.