8000 Add support of checking out closed PR whose branch is deleted by zyoshoka · Pull Request #11098 · cli/cli · GitHub
[go: up one dir, main page]

Skip to content

Conversation

zyoshoka
Copy link

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.

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.
@Copilot Copilot AI review requested due to automatic review settings June 11, 2025 07:16
@zyoshoka zyoshoka requested a review from a team as a code owner June 11, 2025 07:16
@zyoshoka zyoshoka requested a review from andyfeller June 11, 2025 07:16
@zyoshoka zyoshoka temporarily deployed to cli-automation June 11, 2025 07:16 — with GitHub Actions Inactive
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Jun 11, 2025
Copilot
< 8000 div data-view-component="true" class="TimelineItem-body d-flex flex-column flex-md-row flex-justify-start">
Copy link
Contributor
@Copilot Copilot AI left a 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.

@candycandy624

This comment was marked as spam.

@andyfeller
Copy link
Member

I want to highlight our Contributing Guidelines, as we expect that PRs are only created for issues that have been labeled help wanted.

We appreciate your initiative, so please note that:

  • PRs for non-help wanted issues may not be reviewed immediately as they might not align with our current priorities
  • The issue might already be assigned to a team member or planned for a specific release
  • We may need to close this PR. For example, if it conflicts with ongoing work or architectural decisions

What happens next:

  • Our team will review this PR and the associated issues
  • We may add the help wanted label to the issues, if appropriate, and review this pull request
  • In some cases, we may need to close the PR. For example, if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

@andyfeller
Copy link
Member

I've raised some questions within the original issue, will work to understand the scope of this issue before continuing the review.

Copy link
Member
@andyfeller andyfeller left a 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.

Comment on lines 173 to +176
refSpec := fmt.Sprintf("+refs/heads/%s", pr.HeadRefName)
if !pr.IsOpen() {
refSpec = fmt.Sprintf("+refs/pull/%d/head", pr.Number)
}
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external pull request originating outside of the CLI core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support checkout closed PR or PR branch
4 participants
0