KEMBAR78
Compare full head label for determining current PR by rista404 · Pull Request #566 · cli/cli · GitHub
Skip to content

Conversation

@rista404
Copy link
Contributor

I took a look at #561, it wouldn't work for any branch name (regardless of a dot) in forked repos. Traced it to here, pr.HeadLabel() was compared to currentPRHeadRef which for cross repo PRs would be rista404:test-branch == test-branch. Now it's compared to the full label. Tested it in forked and my own repos.

Closes #561

Previously only the `currentPRHeadRef` was compared to `pr.HeadLabel()`
when determining current PR in `status` command. This handles cross-repo
"Current PR" detection.
@rista404
Copy link
Contributor Author

It might also be useful, for forked repos, to see the current user if there is no PR, like so:

Relevant pull requests in user/base-repo

Current branch
  There is no pull request associated with [rista404:test-branch]

I can add that as well if you want!

Copy link
Contributor

@mislav mislav 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 attempting a fix! I think your workaround would work for your specific edge case, but I don't feel like it addresses the root cause.

if edge.Node.HeadLabel() == currentPRHeadRef {
currentPRHeadLabel := currentPRHeadRef
if edge.Node.IsCrossRepository {
currentPRHeadLabel = fmt.Sprintf("%s:%s", currentUsername, currentPRHeadRef)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is the right solution. The currentPRHeadRef value was already supposed to be prefixed with OWNER: in case that the branch is pushed to a fork

cli/command/pr.go

Lines 384 to 386 in 704ce31

// prepend `OWNER:` if this branch is pushed to a fork
if !strings.EqualFold(branchOwner, baseRepo.RepoOwner()) {
prHeadRef = fmt.Sprintf("%s:%s", branchOwner, prHeadRef)

This doesn't happen, and I suspect that it might be because the main command uses determineBaseRepo() to find out the base repository, but prSelectorForCurrentBranch() uses ctx.BaseRepo(), which can (confusingly) return different results.

I have opened #567 to explore an alternate avenue of fixing this; I would appreciate a review!

@rista404
Copy link
Contributor Author

rista404 commented Mar 2, 2020

@mislav thanks for the review/explanation! I'll jump on #567 👍

@mislav mislav closed this in #567 Mar 3, 2020
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.

CLI claims no pr associated with current branch even when one is clearly listed

2 participants