-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add support of checking out closed PR whose branch is deleted #11098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
In addition, if a branch with the same name as a closed PR exists, there is an issue where the new branch is checked out, which will also be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support to check out a closed pull request whose branch has been deleted and addresses a related issue where a branch with the same name as a closed PR exists.
- Adds a new test (TestPRCheckout_closedPR) for handling closed PR checkouts.
- Updates the checkout command logic to use pull request references for closed PRs.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
pkg/cmd/pr/checkout/checkout_test.go | Adds new tests for closed PR scenarios. |
pkg/cmd/pr/checkout/checkout.go | Modifies refSpec logic to fetch pull request refs for closed PRs. |
This comment was marked as spam.
This comment was marked as spam.
I want to highlight our Contributing Guidelines, as we expect that PRs are only created for issues that have been labeled We appreciate your initiative, so please note that:
What happens next:
Thank you for your understanding and contribution to the project! 🙏 |
I've raised some questions within the original issue, will work to understand the scope of this issue before continuing the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience, @zyoshoka! 🙇
Having discussed this with fellow maintainers, we're in agreement that the PR's state isn't the relevant factor here but whether the PR head reference exists locally before falling back to the remote PR reference.
refSpec := fmt.Sprintf("+refs/heads/%s", pr.HeadRefName) | ||
if !pr.IsOpen() { | ||
refSpec = fmt.Sprintf("+refs/pull/%d/head", pr.Number) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: this conditional logic should be refactored to fallback to using the refs/pull/NUMBER
only if refs/heads/HEAD_REF
does not exist.
For more information, see #8628 (comment)
Adds support of checking out a closed PR whose branch is deleted. Closes #8628.
In addition, if a branch with the same name as a closed PR exists, there is an issue where the new branch is checked out, which will also be fixed.