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

Feature request: git url #1177

Open
sjmulder opened this issue May 12, 2016 · 2 comments
Open

Feature request: git url #1177

sjmulder opened this issue May 12, 2016 · 2 comments
Labels

Comments

@sjmulder
Copy link

sjmulder commented May 12, 2016

git-url [REMOTE] [REF] [--] [PATH]

Prints the GitHub URL of the specified item to standard output.

Arguments:
  REMOTE   Use the repository pointed at by the value. Defaults to master.
  REF      A branch, tag or commit
  PATH     A file path

Remarks:
  If a PATH is given, the specified path is linked in the given REF, or if
  not set, to the current branch, tag or commit (if detached).

  If a PATH is not given, the REF itself is linked, or the repository itself
  if not set.

  When REMOTE or REF is ambiguous, both must be supplied. When PATH is
  ambiguous, add a -- argument before it.

Examples:

  $ git url
  https://github.com/github/hub

  $ git url myremote
  https://github.com/myuser/hub

  $ git url 2.2-stable
  https://github.com/github/hub/tree/2.2-stable

  $ git url 88296d1
  https://github.com/github/hub/commit/88296d1

  $ git url README.md
  https://github.com/github/hub/blob/master/README.md

  $ git url 2.2-stable README.md
  https://github.com/github/hub/blob/2.2-stable/README.md

  $ git checkout 2.2-stable
  $ git url README.md
  https://github.com/github/hub/blob/2.2-stable/README.md

  $ git checkout 133ed4e
  $ git url README.md
  https://github.com/github/hub/blob/133ed4e/README.md 
@mislav mislav added the feature label May 12, 2016
@mislav
Copy link
Owner

mislav commented May 12, 2016

This is a nice proposal. Although hub browse -u already covers some of these features, I definitely see a value in smart handling of when branch names, commit SHAs, or file names are passed.

I'm not so sold on this command being called git url, but I'm definitely open for making hub browse working more like this, or making a new command like hub open and deprecating hub browse.

@sjmulder
Copy link
Author

sjmulder commented May 12, 2016

I have to admit I wasn’t aware of hub browse. To me it seems like it could be extended for the above use cases with a handful of changes:

  • Adding a way to specify a remote from which the user and repository should be inferred, perhaps -r upstream or by changing the first positional argument to [REMOTE | [USER/]REPOSITORY], although that could lead to ambiguities
  • Making the [SUBPAGE] argument more flexible by accepting branches and tags, perhaps making the commit/, branch/, etc part optional, essentially making this [SUBPAGE|REF]
  • Adding a [PATH] argument. It would be good to be able to disambiguate from [SUBPAGE|REF]with -- but unfortunately that’s already used. Not sure what to do about that

The behaviour between [SUBPAGE|REF] and [PATH] would then be the same as in the proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants