Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top level command to view various objects in the browser #217

Closed
ampinsk opened this issue Jan 11, 2020 · 9 comments
Closed

Top level command to view various objects in the browser #217

ampinsk opened this issue Jan 11, 2020 · 9 comments
Labels
core This issue is not accepting PRs from outside contributors enhancement a request to improve CLI

Comments

@ampinsk
Copy link
Contributor

ampinsk commented Jan 11, 2020

  • with no args: open the repository on github.com
  • with an arg: open that object on github.com
    • owner/repo
    • branch
    • PR/issue number
    • URL
    • file path (and optionally line number)
@sindresorhus
Copy link

with no args: open the repository

If you're on a non-default branch, commit, or tag, I think that should be opened on GitHub.com, instead of just the main repo view.


It would also be useful to be able to reveal a specific file on GitHub:

gh view source/unicorn.js:34

(This would show the the unicorn.js file at line 34 on GitHub.com)

@vilmibm
Copy link
Contributor

vilmibm commented Feb 4, 2020

I really like the gh view source/unicorn.js:34 suggestion. i'd also love a -p flag that could copy the resulting GH url to your clipboard (or just print it out) instead of opening the browser.

@vilmibm vilmibm added the enhancement a request to improve CLI label Feb 4, 2020
@billygriffin billygriffin changed the title gh view Top level command to view various objects in the browser Feb 7, 2020
@simon04
Copy link

simon04 commented Feb 12, 2020

Some inspirations from lab (Lab wraps Git or Hub):

@bengoism
Copy link

with no args: open the repository

If you're on a non-default branch, commit, or tag, I think that should be opened on GitHub.com, instead of just the main repo view.

It would also be useful to be able to reveal a specific file on GitHub:

gh view source/unicorn.js:34

(This would show the the unicorn.js file at line 34 on GitHub.com)

would be nice if the proposed command gh view accepted a directory as an argument aswell. I quite often want to open my current working directory on github which would then just be gh view .

@jdwolk
Copy link

jdwolk commented Jun 4, 2020

+1 — a feature I sorely miss from hub browse is how it opens GH to the same branch I'm on in my local CLI

@vilmibm vilmibm added the core This issue is not accepting PRs from outside contributors label Oct 5, 2020
@vilmibm
Copy link
Contributor

vilmibm commented Apr 29, 2021

I'll be on PTO the next two weeks so I wanted to leave some thoughts here.

I don't have very strong opinions around implementation for this command but I do have strong feelings about naming it.

No matter what name we go with, we'll be setting a precedent. To date we've been consistent with the format gh <noun> <verb>. We've discussed adding commands of the form gh <verb> but haven't merged any yet. I can see arguments for either direction with web.

noun verb

$ gh web 123         # alias for gh web view 123
$ gh web view 123    # open thing ID 123 in browser
$ gh web shorten 123 # prints shortened URL for thing ID 123

Pro:

  • consistent with other commands
  • leaves room for additional subcommands like shorten

Con:

  • clumsy
  • would be first time having behavior for a parent command (ie gh web)

verb

$ gh browse 123

Pro:

  • brevity
  • echoes the feature over in hub which many people have requested
  • intuitive

Con:

  • inconsistent with other commands
  • no room for expansion (ie to support something like shorten later on)

my preferences

I'm ok with either approach but am ultimately slightly more inclined towards gh browse. gh web ends up being less consistent given that it has behavior at the parent level. If we go with gh browse, I'd like it to occupy a new section in the gh help output to call it out as a singular verb. I think it's more likely that we'll have more commands like this (as several have been suggested...eg gh render) than it is we'll have more stuff to put in gh web.

(NB: we could also go with gh view but billy pointed out this would be confusing; in all other commands, view means view in terminal and not view in browser).

@zneix
Copy link

zneix commented Jun 30, 2021

Just tried gh browse and have some feedback for you:

  • when checked out to a branch which remote tracking branch might be on different repository, e.g. a fork of upstream try to determine the path to that fork and open page of that fork in browser instead of upstream repository when using gh browse with no arguments
  • using gh browse <file> while being checked out to a certain commit / branch / tag should use it instead of opening everything on master branch.

@OliverJAsh
Copy link

OliverJAsh commented Jun 30, 2021

A feature I miss from hub is the ability to open a commit:

hub browse -- commit/b61bb766c8da7c6d08185a4588be72a0c189f011

I would often use this when I needed to share a link to a commit.

@mislav
Copy link
Contributor

mislav commented Jan 11, 2022

The gh browse command shipped last year; we forgot to close this! 🚀

For additional bug reports/feature requests, please open separate issues. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core This issue is not accepting PRs from outside contributors enhancement a request to improve CLI
Projects
None yet
Development

No branches or pull requests

10 participants