Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@metalogical
Copy link
Contributor

for gh pr status

fixes #1132

➜ gh pr status

Relevant pull requests in ...

Current branch
  There is no current branch

Created by you
  ...

Requesting a code review from you
  ...

Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

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

thanks, this looks great! I'd like to see an additional test added; otherwise 👍


currentBranch, err := git.CurrentBranch()
if err != nil {
switch err {
Copy link
Contributor

Choose a reason for hiding this comment

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

I looked through git history and we already had a commit trying to fix this; we regressed because there's no test. I'd like a test added that invokes gh pr status in a no-branch situation to cover this case moving forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've addressed this concern to a degree.

  • update the "blank context" mock to return an ErrNotOnAnyBranch if no branch has been set.
  • add a test to pr_test.go that checks that the command runs to completion if there is no branch.

I don't think this is completely foolproof, since it relies on the mock's behavior staying synchronized with the regular filesystem context, so I'm not 100% happy with it.

But I didn't see any existing tests that set up a real Git repository (on a real filesystem, using real git), and I'm assuming that you don't want to add that with this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was imagining using our CmdStubber's StubError to have the git branch call result in the expected error. Sorry for the back and forth but I'd rather see that approach (unless there's a reason why it wouldn't work that I'm forgetting about).

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.

Thanks for taking care of this!

@metalogical metalogical requested review from mislav and vilmibm June 12, 2020 00:13
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!

@mislav mislav merged commit ab903bd into cli:trunk Jun 24, 2020
@metalogical metalogical deleted the FIX-detached-head branch June 24, 2020 16:34
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.

support detached HEAD git state whenever applicable

3 participants