Skip to content

pr diff#962

Merged
vilmibm merged 8 commits intomasterfrom
pr-diff
May 19, 2020
Merged

pr diff#962
vilmibm merged 8 commits intomasterfrom
pr-diff

Conversation

@vilmibm
Copy link
Copy Markdown
Contributor

@vilmibm vilmibm commented May 18, 2020

Summary

closes #917

This is a first pass on a gh pr diff command. It can be invoked on the current branch's PR, a URL,
or a pr number.

It does not call out to a pager like git diff does.

You can control its use of color with --color={always|never|auto}. It won't colorize in
non-interactive settings.

image

@vilmibm vilmibm requested review from mislav and probablycorey May 18, 2020 22:46
@tierninho
Copy link
Copy Markdown
Contributor

Played around with this and it is looking good.

Should be swap out the error messaging when a user inputs an issue number or non-existent PR? This is the current output:

➜  cli git:(pr-diff) ✗ bin/gh pr diff 917
{"message":"Not Found","documentation_url":"https://developer.github.com/v3/pulls/#get-a-single-pull-request"}

@vilmibm
Copy link
Copy Markdown
Contributor Author

vilmibm commented May 19, 2020

ha yeah should def fix that, oops

@tierninho tierninho requested review from tierninho and removed request for tierninho May 19, 2020 18:14
@tierninho
Copy link
Copy Markdown
Contributor

Looking good now, thanks!

➜  cli git:(pr-diff) ✗ bin/gh pr diff 917
could not find pull request diff: pull request not found

Copy link
Copy Markdown
Contributor

@probablycorey probablycorey left a comment

Choose a reason for hiding this comment

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

Looks good and works well! I left some minor naming suggestions inline.

if err != nil {
return err
}
if !validColor(color) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like how you pulled this logic into a new function. Maybe change the name to something like validColorFlag, otherwise it sounds like it is validating if the string is an actual color.

return fmt.Errorf("could not determine base repo: %w", err)
}

// begin pr resolution boilerplate
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😆

Comment on lines +104 to +108
case bold(diffLine):
output = utils.Bold(diffLine)
case green(diffLine):
output = utils.Green(diffLine)
case red(diffLine):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe naming these function with the line content would better. So instead of green it would be isAdditionLine.
For the bold it could be something like isHeaderLine

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.

gh pr diff

4 participants