зеркало из https://github.com/mislav/hub.git
`hub browse` with no repository specified defaults to current repo
useful for jumping to the GitHub page of the repo checked out in the current directory
This commit is contained in:
Родитель
236cfe67a8
Коммит
ef3271a896
|
@ -146,6 +146,9 @@ superpowers:
|
|||
|
||||
### git browse
|
||||
|
||||
$ git browse
|
||||
> open http://github.com/CURRENT_REPO
|
||||
|
||||
$ git browse schacon/ticgit
|
||||
> open http://github.com/schacon/ticgit
|
||||
|
||||
|
|
|
@ -143,6 +143,9 @@ module Hub
|
|||
args.after after
|
||||
end
|
||||
|
||||
# $ hub browse
|
||||
# > open http://github.com/CURRENT_REPO
|
||||
#
|
||||
# $ hub browse pjhyett/github-services
|
||||
# > open http://github.com/pjhyett/github-services
|
||||
#
|
||||
|
@ -159,12 +162,20 @@ module Hub
|
|||
protocol = args.delete('-p') ? 'https' : 'http'
|
||||
dest = args.pop
|
||||
|
||||
if dest.include? '/'
|
||||
# $ hub browse pjhyett/github-services
|
||||
user, repo = dest.split('/')
|
||||
if dest
|
||||
if dest.include? '/'
|
||||
# $ hub browse pjhyett/github-services
|
||||
user, repo = dest.split('/')
|
||||
else
|
||||
# $ hub browse github-services
|
||||
user, repo = github_user, dest
|
||||
end
|
||||
elsif !OWNER.empty?
|
||||
# $ hub browse
|
||||
user, repo = OWNER, REPO
|
||||
else
|
||||
# $ hub browse github-services
|
||||
user, repo = github_user, dest
|
||||
$stderr.puts "Usage: hub browse [<USER>/]<REPOSITORY>"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
args.executable = ENV['BROWSER'] || 'open'
|
||||
|
|
|
@ -65,10 +65,11 @@ Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing
|
|||
multiple \fBgit push\fR commands.
|
||||
.
|
||||
.TP
|
||||
\fBgit browse\fR [\fB\-p\fR] [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR
|
||||
\fBgit browse\fR [\fB\-p\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR]
|
||||
Open repository's GitHub page in the system's default web browser
|
||||
using \fBopen(1)\fR or the \fBBROWSER\fR env variable. Use \fB\-p\fR to open a
|
||||
page with https.
|
||||
page with https. If the repository isn't specified, \fBbrowse\fR opens
|
||||
the page of the repository found in the current directory.
|
||||
.
|
||||
.TP
|
||||
\fBgit help\fR
|
||||
|
|
|
@ -122,11 +122,11 @@ then uses your GitHub login.</p></dd>
|
|||
<dd><p>Push <var>REF</var> to each of <var>REMOTE-1</var> through <var>REMOTE-N</var> by executing
|
||||
multiple <code>git push</code> commands.</p></dd>
|
||||
<dt>
|
||||
<code>git browse</code> [<code>-p</code>] [<var>USER</var><code>/</code>]<var>REPOSITORY</var>
|
||||
</dt>
|
||||
<code>git browse</code> [<code>-p</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>]</dt>
|
||||
<dd><p>Open repository's GitHub page in the system's default web browser
|
||||
using <code>open(1)</code> or the <code>BROWSER</code> env variable. Use <code>-p</code> to open a
|
||||
page with https.</p></dd>
|
||||
page with https. If the repository isn't specified, <code>browse</code> opens
|
||||
the page of the repository found in the current directory.</p></dd>
|
||||
<dt><code>git help</code></dt>
|
||||
<dd><p>Display enhanced git-help(1).</p></dd>
|
||||
</dl>
|
||||
|
|
|
@ -46,10 +46,11 @@ After configuring the alias, the following commands have superpowers:
|
|||
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
|
||||
multiple `git push` commands.
|
||||
|
||||
* `git browse` [`-p`] [<USER>`/`]<REPOSITORY>:
|
||||
* `git browse` [`-p`] [[<USER>`/`]<REPOSITORY>]:
|
||||
Open repository's GitHub page in the system's default web browser
|
||||
using `open(1)` or the `BROWSER` env variable. Use `-p` to open a
|
||||
page with https.
|
||||
page with https. If the repository isn't specified, `browse` opens
|
||||
the page of the repository found in the current directory.
|
||||
|
||||
* `git help`:
|
||||
Display enhanced git-help(1).
|
||||
|
|
|
@ -182,4 +182,18 @@ config
|
|||
def test_hub_open_self_private
|
||||
assert_command "browse -p github", "open https://github.com/tpw/github"
|
||||
end
|
||||
|
||||
def test_hub_open_current
|
||||
assert_command "browse", "open http://github.com/defunkt/hub"
|
||||
end
|
||||
|
||||
def test_hub_open_current_private
|
||||
assert_command "browse -p", "open https://github.com/defunkt/hub"
|
||||
end
|
||||
|
||||
def test_hub_open_no_repo
|
||||
Hub::Commands::OWNER.replace("")
|
||||
input = "browse"
|
||||
assert_equal "Usage: hub browse [<USER>/]<REPOSITORY>\n", hub(input)
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче