Skip to content

feat: Auto-detect repo and PR from current git branch#78

Open
sideshowbarker wants to merge 3 commits intodanobi:masterfrom
sideshowbarker:auto-detect-pr
Open

feat: Auto-detect repo and PR from current git branch#78
sideshowbarker wants to merge 3 commits intodanobi:masterfrom
sideshowbarker:auto-detect-pr

Conversation

@sideshowbarker
Copy link
Copy Markdown

This change enables running prr get, prr edit, or prr submit without an argument — in which case, prr now auto-detects the repo and PR number by:

  1. Parsing the git remote URL: tries “upstream” first (for fork workflows), then, if that's not found, falls back to “origin”.
  2. Getting the current branch name.
  3. Querying the GitHub API for the PR associated with that branch.

When invoked from inside a GitHub repo clone on a PR branch, all that enables you to just run prr get, prr edit, or prr submit with no argument.

@sideshowbarker sideshowbarker force-pushed the auto-detect-pr branch 3 times, most recently from 3621e6a to 14b18ee Compare January 18, 2026 22:41
This change enables running “prr get”, “prr edit”, or “prr submit” without
an argument — in which case, prr now auto-detects the repo and PR number by:

1. Parsing the git remote URL: tries “upstream” first (for fork workflows),
   then, if that's not found, falls back to “origin”.
2. Getting the current branch name.
3. Querying the GitHub API for the PR associated with that branch.

For fork workflows, the “upstream” remote identifies the repository to query,
while the “origin” remote identifies the fork owner for the head branch filter.

When invoked from inside a GitHub repo clone on a PR branch, all that enables
you to just run “prr get”, “prr edit”, or “prr submit” with no argument.
@danobi
Copy link
Copy Markdown
Owner

danobi commented Jan 20, 2026

Thanks for the PR! I will take a look tomorrow.

Copy link
Copy Markdown
Owner

@danobi danobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature seems useful! Overall seems reasonable, some nits below.

Comment thread src/prr.rs
Comment thread src/prr.rs Outdated
Comment thread src/prr.rs Outdated
Add `upstream_remote` and `origin_remote` optional fields to the
`[local]` config section in `.prr.toml`. These override the default
remote names ("upstream" and "origin") used when auto-detecting the
repository and PR from the current git branch. Useful for setups
where remotes are named differently.
Instead of silently picking the first PR, error out and ask the user
to specify the PR explicitly — the ambiguity is too risky.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants