X Tutup
Skip to content

Add gh pr view#24

Merged
probablycorey merged 7 commits intomasterfrom
add-pr-show
Oct 16, 2019
Merged

Add gh pr view#24
probablycorey merged 7 commits intomasterfrom
add-pr-show

Conversation

@probablycorey
Copy link
Copy Markdown
Contributor

gh pr view [pr-number]

Opens the PR in the browser. If no pr-number is given it opens the PR of the current branch. I want to add tests to this as well, but the test PR hasn't been merged yet, so I'm waiting for that.

@probablycorey probablycorey self-assigned this Oct 15, 2019
@probablycorey probablycorey requested a review from a team October 15, 2019 22:33
return nil
}

func prView(cmd *cobra.Command, args []string) error {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So there is no name collision in the command package, I started naming these functions as command + subcommand (prView and prList)

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.

Great idea!

if prNumber, err := strconv.Atoi(args[0]); err == nil {
openURL = project.WebURL("", "", fmt.Sprintf("pull/%d", prNumber))
} else {
return fmt.Errorf("invalid pull request number: '%s'", args[0])
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Opening via branch name is another option to consider here.

Copy link
Copy Markdown
Contributor

@tierninho tierninho left a comment

Choose a reason for hiding this comment

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

Works well, but I noticed that gh pr view, gh pr view 24 and gh pr view 23 all resulted in the same output, when I was on the corresponding branch for 24. I was assuming that if the pr was still open I could see it show up with this command.

➜  gh-cli git:(add-pr-show) gh pr view 23
? PRs you might be interested in [24] Add `gh pr view`

Copy link
Copy Markdown
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.

Heads up: might have accidentally checked in gh-cli

return nil
}

func prView(cmd *cobra.Command, args []string) error {
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.

Great idea!

Co-Authored-By: Mislav Marohnić <mislav@github.com>
@probablycorey
Copy link
Copy Markdown
Contributor Author

@tierninho Did gh pr view 23 and gh pr view 24 have the same output in the terminal, or did they open up the same page in the browser?

@tierninho
Copy link
Copy Markdown
Contributor

@probablycorey I got a mixed bag of results regarding the output of gh pr view 23 and gh pr view 24. Maybe my expectations are not aligned with the intention of the command? I assume this cmd can be used on any branch to view any PR.

The browser part worked fine for whatever option was presented.

When on master:

➜  gh-cli git:(master) gh pr view 23
please provide options to select from
➜  gh-cli git:(master) gh pr view 24
please provide options to select from

When on the branch associated with PR 23:

➜  gh-cli git:(pr-create-improve) gh pr view 23
? PRs you might be interested in  [Use arrows to move, type to filter]
> [18] testing
➜  gh-cli git:(pr-create-improve) gh pr view 24
? PRs you might be interested in  [Use arrows to move, type to filter]
> [18] testing

When on the branch associated with PR 24:

➜  gh-cli git:(add-pr-show) gh pr view 23
? PRs you might be interested in  [Use arrows to move, type to filter]
> [24] Add `gh pr view`
➜  gh-cli git:(add-pr-show) gh pr view 24
? PRs you might be interested in  [Use arrows to move, type to filter]
> [24] Add `gh pr view`

@probablycorey probablycorey changed the base branch from style-pr-list to master October 16, 2019 19:29
@probablycorey
Copy link
Copy Markdown
Contributor Author

@tierninho weird! I don't see any output when I run the command

It looks like your version is also running the interactive gh pr command. Maybe it isn't build the the gh binary properly?

@tierninho
Copy link
Copy Markdown
Contributor

Hmm, not sure.

I just ran these commands and it worked perfectly:

➜  gh-cli git:(add-pr-show) go run . pr view 24
Opening https://github.com/github/gh-cli/pull/24 in your browser.
➜  gh-cli git:(add-pr-show) go run . pr view 23
Opening https://github.com/github/gh-cli/pull/23 in your browser.

@probablycorey probablycorey merged commit eab87f7 into master Oct 16, 2019
@mislav mislav deleted the add-pr-show branch October 31, 2019 10:14
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.

3 participants

X Tutup