fix(submit): check for existing PR before prompting for details#52
Merged
fix(submit): check for existing PR before prompting for details#52
Conversation
Owner
Author
📚 Pull Request Stack
Managed by gh-stack |
When a branch already has a PR on GitHub but the association isn't stored in local git config, `gh stack submit` would prompt the user for PR title and description, only to discover (via API error) that the PR already exists. Now we call `FindPRByHead` before prompting. If a PR exists, we adopt it immediately without unnecessary prompting. Refactored `adoptExistingPR` to extract `adoptExistingPRDirect`, avoiding a redundant API call when we've already fetched the PR.
4513738 to
c0a5148
Compare
There was a problem hiding this comment.
Pull request overview
This pull request improves the user experience when submitting a branch that already has a PR on GitHub but lacks local configuration. Previously, users would be prompted for PR title and description, only to then discover (via API error) that the PR already exists. Now, the code checks for an existing PR before prompting, and if found, adopts it immediately.
Changes:
- Added early PR existence check in
createPRForBranchbefore prompting for PR details - Refactored
adoptExistingPRto extractadoptExistingPRDirectfor code reuse - Reduced unnecessary API calls by reusing fetched PR data
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a branch already has a PR on GitHub but the association isn't stored in local git config,
gh stack submitwould prompt the user for PR title and description, only to discover (via API error) that the PR already exists.Now we call
FindPRByHeadbefore prompting. If a PR exists, we adopt it immediately without unnecessary prompting.Refactored
adoptExistingPRto extractadoptExistingPRDirect, avoiding a redundant API call when we've already fetched the PR.