git-hub 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.md +6 -1
- data/README.md +28 -1
- data/lib/hub/commands.rb +67 -6
- data/lib/hub/version.rb +1 -1
- data/man/hub.1 +27 -1
- data/man/hub.1.html +23 -1
- data/man/hub.1.ron +20 -0
- data/test/hub_test.rb +48 -1
- metadata +2 -2
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -36,7 +36,8 @@ Install
|
|
36
36
|
|
37
37
|
`hub` is most easily installed as a standalone script:
|
38
38
|
|
39
|
-
curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub &&
|
39
|
+
curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub &&
|
40
|
+
chmod 755 ~/bin/hub
|
40
41
|
|
41
42
|
Assuming `~/bin/` is in your `$PATH`, you're ready to roll:
|
42
43
|
|
@@ -56,6 +57,17 @@ Though not recommended, `hub` can also be installed as a RubyGem:
|
|
56
57
|
|
57
58
|
(Yes, the gem name is `git-hub`.)
|
58
59
|
|
60
|
+
(It's not recommended because of the RubyGems startup time. See [this
|
61
|
+
gist][speed] for information.)
|
62
|
+
|
63
|
+
### Standalone via RubyGems
|
64
|
+
|
65
|
+
Yes, the gem name is still `git-hub`:
|
66
|
+
|
67
|
+
$ gem install git-hub
|
68
|
+
$ hub hub standalone > ~/bin/hub && chmod 755 ~/bin/hub
|
69
|
+
$ gem uninstall git-hub
|
70
|
+
|
59
71
|
### Source
|
60
72
|
|
61
73
|
You can also install from source:
|
@@ -129,6 +141,20 @@ superpowers:
|
|
129
141
|
> git push staging bert_timeout
|
130
142
|
> git push qa bert_timeout
|
131
143
|
|
144
|
+
### git browse
|
145
|
+
|
146
|
+
$ git browse schacon/ticgit
|
147
|
+
> open http://github.com/schacon/ticgit
|
148
|
+
|
149
|
+
$ git browse -p schacon/ticgit
|
150
|
+
> open http://github.com/schacon/ticgit
|
151
|
+
|
152
|
+
$ git browse resque
|
153
|
+
> open http://github.com/YOUR_USER/resque
|
154
|
+
|
155
|
+
$ git browse -p resque
|
156
|
+
> open https://github.com:YOUR_USER/resque
|
157
|
+
|
132
158
|
### git help
|
133
159
|
|
134
160
|
$ git help
|
@@ -216,3 +242,4 @@ Chris Wanstrath :: chris@ozmm.org :: @defunkt
|
|
216
242
|
|
217
243
|
[0]: http://help.github.com/forking/
|
218
244
|
[1]: http://github.com/defunkt/hub/issues
|
245
|
+
[speed]: http://gist.github.com/284823
|
data/lib/hub/commands.rb
CHANGED
@@ -44,7 +44,7 @@ module Hub
|
|
44
44
|
if ORIGIN =~ %r{\bgithub\.com[:/](.+)/(.+).git$}
|
45
45
|
REPO = $2
|
46
46
|
else
|
47
|
-
REPO =
|
47
|
+
REPO = File.basename(Dir.pwd)
|
48
48
|
end
|
49
49
|
|
50
50
|
# $ hub clone rtomayko/tilt
|
@@ -52,17 +52,35 @@ module Hub
|
|
52
52
|
#
|
53
53
|
# $ hub clone -p kneath/hemingway
|
54
54
|
# > git clone git@github.com:kneath/hemingway.git
|
55
|
+
#
|
56
|
+
# $ hub clone tilt
|
57
|
+
# > git clone git://github.com/YOUR_LOGIN/tilt.
|
58
|
+
#
|
59
|
+
# $ hub clone -p github
|
60
|
+
# > git clone git@github.com:YOUR_LOGIN/hemingway.git
|
55
61
|
def clone(args)
|
56
62
|
ssh = args.delete('-p')
|
57
|
-
|
58
|
-
|
59
|
-
|
63
|
+
|
64
|
+
last_args = args[1..-1].reject { |arg| arg == "--" }.last(3)
|
65
|
+
last_args.each do |arg|
|
66
|
+
if arg =~ /^-/
|
67
|
+
# Skip mandatory arguments.
|
68
|
+
last_args.shift if arg =~ /^(--(ref|o|br|u|t|d)[^=]+|-(o|b|u|d))$/
|
69
|
+
next
|
70
|
+
end
|
71
|
+
|
72
|
+
if arg =~ %r{.+?://|.+?@} || File.directory?(arg)
|
73
|
+
# Bail out early for URLs and local paths.
|
74
|
+
break
|
75
|
+
elsif arg.scan('/').size == 1 && !arg.include?(':')
|
76
|
+
# $ hub clone rtomayko/tilt
|
60
77
|
url = ssh ? PRIVATE : PUBLIC
|
61
|
-
args[
|
78
|
+
args[args.index(arg)] = url % arg.split('/')
|
62
79
|
break
|
63
80
|
elsif arg !~ /:|\//
|
81
|
+
# $ hub clone tilt
|
64
82
|
url = ssh ? PRIVATE : PUBLIC
|
65
|
-
args[
|
83
|
+
args[args.index(arg)] = url % [ github_user, arg ]
|
66
84
|
break
|
67
85
|
end
|
68
86
|
end
|
@@ -117,6 +135,49 @@ module Hub
|
|
117
135
|
args.after after
|
118
136
|
end
|
119
137
|
|
138
|
+
# $ hub browse pjhyett/github-services
|
139
|
+
# > open http://github.com/pjhyett/github-services
|
140
|
+
#
|
141
|
+
# $ hub browse -p pjhyett/github-fi
|
142
|
+
# > open https://github.com/pjhyett/github-fi
|
143
|
+
#
|
144
|
+
# $ hub browse github-services
|
145
|
+
# > open http://github.com/YOUR_LOGIN/github-services
|
146
|
+
#
|
147
|
+
# $ hub browse -p github-fi
|
148
|
+
# > open https://github.com/YOUR_LOGIN/github-fi
|
149
|
+
def browse(args)
|
150
|
+
protocol = args.delete('-p') ? 'https' : 'http'
|
151
|
+
|
152
|
+
if args.last.include? '/'
|
153
|
+
# $ hub browse pjhyett/github-services
|
154
|
+
user, repo = args.last.split('/')
|
155
|
+
else
|
156
|
+
# $ hub browse github-services
|
157
|
+
user = github_user
|
158
|
+
repo = args.last
|
159
|
+
end
|
160
|
+
|
161
|
+
browser = ENV['BROWSER'] || "open"
|
162
|
+
exec "#{browser} #{protocol}://github.com/#{user}/#{repo}"
|
163
|
+
end
|
164
|
+
|
165
|
+
# $ hub hub standalone
|
166
|
+
# Prints the "standalone" version of hub for an easy, memorable
|
167
|
+
# installation sequence:
|
168
|
+
#
|
169
|
+
# $ gem install git-hub
|
170
|
+
# $ hub standalone > ~/bin/standalone
|
171
|
+
# $ gem uninstall git-hub
|
172
|
+
def hub(args)
|
173
|
+
return help(args) unless args[1] == 'standalone'
|
174
|
+
require 'hub/standalone'
|
175
|
+
puts Hub::Standalone.build
|
176
|
+
exit
|
177
|
+
rescue LoadError
|
178
|
+
abort "hub is running in standalone mode."
|
179
|
+
end
|
180
|
+
|
120
181
|
def alias(args)
|
121
182
|
shells = {
|
122
183
|
'sh' => 'alias git=hub',
|
data/lib/hub/version.rb
CHANGED
data/man/hub.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ron/v0.3
|
2
2
|
.\" http://github.com/rtomayko/ron/
|
3
3
|
.
|
4
|
-
.TH "HUB" "1" "
|
4
|
+
.TH "HUB" "1" "January 2010" "DEFUNKT" "Git Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBhub\fR \-\- git + hub = github
|
@@ -24,6 +24,9 @@
|
|
24
24
|
\fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR]
|
25
25
|
.
|
26
26
|
.br
|
27
|
+
\fBgit browse\fR [\fB\-p\fR] [\fIUSER\fR/]\fIREPOSITORY\fR
|
28
|
+
.
|
29
|
+
.br
|
27
30
|
.
|
28
31
|
.SH "DESCRIPTION"
|
29
32
|
\fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion. The
|
@@ -61,6 +64,12 @@ Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing
|
|
61
64
|
multiple \fBgit push\fR commands.
|
62
65
|
.
|
63
66
|
.TP
|
67
|
+
\fBgit browse\fR [\fB\-p\fR] [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR
|
68
|
+
Open repository's GitHub page in the system's default web browser
|
69
|
+
using \fBopen(1)\fR or the \fBBROWSER\fR env variable. Use \fB\-p\fR to open a
|
70
|
+
page with https.
|
71
|
+
.
|
72
|
+
.TP
|
64
73
|
\fBgit help\fR
|
65
74
|
Display enhanced git\-help(1).
|
66
75
|
.
|
@@ -159,6 +168,23 @@ $ git push origin,staging,qa bert_timeout
|
|
159
168
|
.
|
160
169
|
.fi
|
161
170
|
.
|
171
|
+
.SS "git browse"
|
172
|
+
.
|
173
|
+
.nf
|
174
|
+
|
175
|
+
$ git browse schacon/ticgit
|
176
|
+
> open http://github.com/schacon/ticgit
|
177
|
+
$ git browse \-p schacon/ticgit
|
178
|
+
> open http://github.com/schacon/ticgit
|
179
|
+
|
180
|
+
$ git browse resque
|
181
|
+
> open http://github.com/YOUR_USER/resque
|
182
|
+
|
183
|
+
$ git browse \-p resque
|
184
|
+
> open https://github.com:YOUR_USER/resque
|
185
|
+
.
|
186
|
+
.fi
|
187
|
+
.
|
162
188
|
.SS "git help"
|
163
189
|
.
|
164
190
|
.nf
|
data/man/hub.1.html
CHANGED
@@ -73,6 +73,7 @@
|
|
73
73
|
<p><code>git init -g</code> <var>OPTIONS</var> <br>
|
74
74
|
<code>git clone</code> [<code>-p</code>] <var>OPTIONS</var> [<var>USER</var>/]<var>REPOSITORY</var> <var>DIRECTORY</var> <br>
|
75
75
|
<code>git remote add</code> [<code>-p</code>] <var>OPTIONS</var> <var>USER</var>[/<var>REPOSITORY</var>] <br>
|
76
|
+
<code>git browse</code> [<code>-p</code>] [<var>USER</var>/]<var>REPOSITORY</var> <br>
|
76
77
|
</p>
|
77
78
|
|
78
79
|
<h2>DESCRIPTION</h2>
|
@@ -119,6 +120,12 @@ current working directory is used. With <code>-p</code>, use private remote
|
|
119
120
|
</dt>
|
120
121
|
<dd><p>Push <var>REF</var> to each of <var>REMOTE-1</var> through <var>REMOTE-N</var> by executing
|
121
122
|
multiple <code>git push</code> commands.</p></dd>
|
123
|
+
<dt>
|
124
|
+
<code>git browse</code> [<code>-p</code>] [<var>USER</var><code>/</code>]<var>REPOSITORY</var>
|
125
|
+
</dt>
|
126
|
+
<dd><p>Open repository's GitHub page in the system's default web browser
|
127
|
+
using <code>open(1)</code> or the <code>BROWSER</code> env variable. Use <code>-p</code> to open a
|
128
|
+
page with https.</p></dd>
|
122
129
|
<dt><code>git help</code></dt>
|
123
130
|
<dd><p>Display enhanced git-help(1).</p></dd>
|
124
131
|
</dl>
|
@@ -186,6 +193,21 @@ $ git remote add -p rtomayko
|
|
186
193
|
> git push qa bert_timeout
|
187
194
|
</code></pre>
|
188
195
|
|
196
|
+
<h3>git browse</h3>
|
197
|
+
|
198
|
+
<pre><code>$ git browse schacon/ticgit
|
199
|
+
> open http://github.com/schacon/ticgit
|
200
|
+
|
201
|
+
$ git browse -p schacon/ticgit
|
202
|
+
> open http://github.com/schacon/ticgit
|
203
|
+
|
204
|
+
$ git browse resque
|
205
|
+
> open http://github.com/YOUR_USER/resque
|
206
|
+
|
207
|
+
$ git browse -p resque
|
208
|
+
> open https://github.com:YOUR_USER/resque
|
209
|
+
</code></pre>
|
210
|
+
|
189
211
|
<h3>git help</h3>
|
190
212
|
|
191
213
|
<pre><code>$ git help
|
@@ -210,7 +232,7 @@ $ git help hub
|
|
210
232
|
|
211
233
|
<ol class='foot man'>
|
212
234
|
<li class='tl'>DEFUNKT</li>
|
213
|
-
<li class='tc'>
|
235
|
+
<li class='tc'>January 2010</li>
|
214
236
|
<li class='tr'>hub(1)</li>
|
215
237
|
</ol>
|
216
238
|
|
data/man/hub.1.ron
CHANGED
@@ -9,6 +9,7 @@ hub(1) -- git + hub = github
|
|
9
9
|
`git init -g` <OPTIONS>
|
10
10
|
`git clone` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>
|
11
11
|
`git remote add` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>]
|
12
|
+
`git browse` [`-p`] [<USER>/]<REPOSITORY>
|
12
13
|
|
13
14
|
## DESCRIPTION
|
14
15
|
|
@@ -44,6 +45,11 @@ After configuring the alias, the following commands have superpowers:
|
|
44
45
|
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
|
45
46
|
multiple `git push` commands.
|
46
47
|
|
48
|
+
* `git browse` [`-p`] [<USER>`/`]<REPOSITORY>:
|
49
|
+
Open repository's GitHub page in the system's default web browser
|
50
|
+
using `open(1)` or the `BROWSER` env variable. Use `-p` to open a
|
51
|
+
page with https.
|
52
|
+
|
47
53
|
* `git help`:
|
48
54
|
Display enhanced git-help(1).
|
49
55
|
|
@@ -102,6 +108,20 @@ cloning:
|
|
102
108
|
> git push staging bert_timeout
|
103
109
|
> git push qa bert_timeout
|
104
110
|
|
111
|
+
### git browse
|
112
|
+
|
113
|
+
$ git browse schacon/ticgit
|
114
|
+
> open http://github.com/schacon/ticgit
|
115
|
+
|
116
|
+
$ git browse -p schacon/ticgit
|
117
|
+
> open http://github.com/schacon/ticgit
|
118
|
+
|
119
|
+
$ git browse resque
|
120
|
+
> open http://github.com/YOUR_USER/resque
|
121
|
+
|
122
|
+
$ git browse -p resque
|
123
|
+
> open https://github.com:YOUR_USER/resque
|
124
|
+
|
105
125
|
### git help
|
106
126
|
|
107
127
|
$ git help
|
data/test/hub_test.rb
CHANGED
@@ -30,6 +30,12 @@ class HubTest < Test::Unit::TestCase
|
|
30
30
|
assert_command input, command
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_clone_with_arguments_and_path
|
34
|
+
input = "clone --bare -o master -- resque"
|
35
|
+
command = "git clone --bare -o master -- git://github.com/tpw/resque.git"
|
36
|
+
assert_command input, command
|
37
|
+
end
|
38
|
+
|
33
39
|
def test_your_private_clone_fails_without_config
|
34
40
|
out = hub("clone -p mustache") do
|
35
41
|
Hub::Commands::USER.replace("")
|
@@ -58,6 +64,18 @@ class HubTest < Test::Unit::TestCase
|
|
58
64
|
assert_command input, command
|
59
65
|
end
|
60
66
|
|
67
|
+
def test_normal_public_clone_with_path
|
68
|
+
input = "clone git://github.com/rtomayko/ron.git ron-dev"
|
69
|
+
command = "git clone git://github.com/rtomayko/ron.git ron-dev"
|
70
|
+
assert_command input, command
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_normal_clone_from_path
|
74
|
+
input = "clone ./test"
|
75
|
+
command = "git clone ./test"
|
76
|
+
assert_command input, command
|
77
|
+
end
|
78
|
+
|
61
79
|
def test_private_remote
|
62
80
|
input = "remote add -p rtomayko"
|
63
81
|
command = "git remote add rtomayko git@github.com:rtomayko/hub.git"
|
@@ -99,7 +117,7 @@ class HubTest < Test::Unit::TestCase
|
|
99
117
|
def test_version
|
100
118
|
out = hub('--version')
|
101
119
|
assert_includes "git version 1.6", out
|
102
|
-
assert_includes "hub version
|
120
|
+
assert_includes "hub version #{Hub::Version}", out
|
103
121
|
end
|
104
122
|
|
105
123
|
def test_help
|
@@ -128,4 +146,33 @@ config
|
|
128
146
|
end
|
129
147
|
assert_equal "** Can't find groff(1)\n", help_manpage
|
130
148
|
end
|
149
|
+
|
150
|
+
def test_hub_standalone
|
151
|
+
help_standalone = hub("hub standalone")
|
152
|
+
assert_equal Hub::Standalone.build, help_standalone
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_hub_open
|
156
|
+
input = "browse mojombo/bert"
|
157
|
+
command = "http://github.com/mojombo/bert\n"
|
158
|
+
assert_equal command, hub(input) { ENV['BROWSER'] = 'echo' }
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_hub_open_private
|
162
|
+
input = "browse -p bmizerany/sinatra"
|
163
|
+
command = "https://github.com/bmizerany/sinatra\n"
|
164
|
+
assert_equal command, hub(input) { ENV['BROWSER'] = 'echo' }
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_hub_open_self
|
168
|
+
input = "browse resque"
|
169
|
+
command = "http://github.com/tpw/resque\n"
|
170
|
+
assert_equal command, hub(input) { ENV['BROWSER'] = 'echo' }
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_hub_open_self_private
|
174
|
+
input = "browse -p github"
|
175
|
+
command = "https://github.com/tpw/github\n"
|
176
|
+
assert_equal command, hub(input) { ENV['BROWSER'] = 'echo' }
|
177
|
+
end
|
131
178
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-23 00:00:00 -08:00
|
13
13
|
default_executable: hub
|
14
14
|
dependencies: []
|
15
15
|
|