git-hub 1.0.2 → 1.0.3

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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.3 (2010-03-10)
2
+
3
+ * Bugfix: `hub remote` for repos with -, /, etc
4
+
1
5
  ## 1.0.2 (2010-03-07)
2
6
 
3
7
  * Bugfix: `hub remote -f name` (for real this time)
data/Rakefile CHANGED
@@ -24,12 +24,12 @@ task :standalone => :load_hub do
24
24
  end
25
25
 
26
26
  desc "Build hub manual"
27
- task :build_man do
27
+ task "man:build" do
28
28
  sh "ron -br5 --organization=DEFUNKT --manual='Git Manual' man/*.ron"
29
29
  end
30
30
 
31
31
  desc "Show hub manual"
32
- task :man => :build_man do
32
+ task :man => "man:build" do
33
33
  exec "man man/hub.1"
34
34
  end
35
35
 
@@ -109,16 +109,16 @@ task :publish => [ :test, :gemspec, :build ] do
109
109
  end
110
110
 
111
111
  desc "Publish to GitHub Pages"
112
- task :pages => [ :build_man, :check_dirty, :standalone ] do
112
+ task :pages => [ "man:build", :check_dirty, :standalone ] do
113
113
  cp "man/hub.1.html", "html"
114
- `git checkout gh-pages`
115
- `mv hub standalone`
116
- `git add standalone*`
117
- `mv html hub.1.html`
118
- `git add hub.1.html`
119
- `git commit -m "update standalone"`
120
- `git push origin gh-pages`
121
- `git checkout master`
114
+ sh "git checkout gh-pages"
115
+ sh "mv hub standalone"
116
+ sh "git add standalone*"
117
+ sh "mv html hub.1.html"
118
+ sh "git add hub.1.html"
119
+ sh "git commit -m 'update standalone'"
120
+ sh "git push origin gh-pages"
121
+ sh "git checkout master"
122
122
  puts :done
123
123
  end
124
124
 
data/lib/hub/commands.rb CHANGED
@@ -108,46 +108,31 @@ module Hub
108
108
  # $ hub remote add origin
109
109
  # > git remote add origin git://github.com/YOUR_LOGIN/THIS_REPO.git
110
110
  def remote(args)
111
- return unless args[1] == 'add'
111
+ return if args[1] != 'add' or args.last =~ %r{.+?://|.+?@}
112
112
 
113
113
  ssh = args.delete('-p')
114
114
  url = ssh ? PRIVATE : PUBLIC
115
-
116
- if args.last =~ /\b(\w+)\/(\w+)/
117
- # user/repo
118
- user, repo = $1, $2
119
-
120
- if args.words[-2] == args.words[1]
121
- # rtomayko/tilt => rtomayko
122
- # Make sure you dance around flags.
123
- idx = args.index( args.words[-1] )
124
- args[idx] = user
125
- else
126
- # They're specifying the remote name manually (e.g.
127
- # git remote add blah rtomayko/tilt), so just drop the last
128
- # argument.
129
- args.replace args[0...-1]
130
- end
131
-
132
- args << url % [ user, repo ]
133
- elsif args.last !~ /:|\//
134
- if args.words[2] == 'origin' && args.words[3].nil?
135
- # Origin special case.
136
- user = github_user
137
- else
138
- # Assume no : or / means GitHub user.
139
- user = args.last
140
- end
141
-
142
- if args.words[-2] != args.words[1]
143
- # They're specifying the remote name manually (e.g.
144
- # git remote add blah rtomayko), so just drop the last
145
- # argument.
146
- args.replace args[0...-1]
147
- end
148
-
149
- args << url % [ user, REPO ]
115
+
116
+ # user/repo
117
+ args.last =~ /\b(.+?)(?:\/(.+))?$/
118
+ user, repo = $1, $2 || REPO
119
+
120
+ if args.words[2] == 'origin' && args.words[3].nil?
121
+ # Origin special case.
122
+ user = github_user
123
+ elsif args.words[-2] == args.words[1]
124
+ # rtomayko/tilt => rtomayko
125
+ # Make sure you dance around flags.
126
+ idx = args.index( args.words[-1] )
127
+ args[idx] = user
128
+ else
129
+ # They're specifying the remote name manually (e.g.
130
+ # git remote add blah rtomayko/tilt), so just drop the last
131
+ # argument.
132
+ args.replace args[0...-1]
150
133
  end
134
+
135
+ args << url % [ user, repo ]
151
136
  end
152
137
 
153
138
  # $ hub init -g
data/lib/hub/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hub
2
- Version = '1.0.2'
2
+ Version = '1.0.3'
3
3
  end
data/man/hub.1 CHANGED
@@ -10,53 +10,53 @@
10
10
  \fBhub\fR \fICOMMAND\fR \fIOPTIONS\fR
11
11
  .
12
12
  .br
13
- \fBhub alias\fR [\fB\-s\fR] \fISHELL\fR
13
+ \fBhub alias\fR [\fB-s\fR] \fISHELL\fR
14
14
  .
15
15
  .br
16
16
  .
17
17
  .P
18
- \fBgit init \-g\fR \fIOPTIONS\fR
18
+ \fBgit init -g\fR \fIOPTIONS\fR
19
19
  .
20
20
  .br
21
- \fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
21
+ \fBgit clone\fR [\fB-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
22
22
  .
23
23
  .br
24
- \fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR]
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
27
+ \fBgit browse\fR [\fB-p\fR] [\fIUSER\fR/]\fIREPOSITORY\fR
28
28
  .
29
29
  .br
30
- \fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
30
+ \fBgit submodule add\fR [\fB-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
31
31
  .
32
32
  .SH "DESCRIPTION"
33
33
  \fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion. The
34
34
  alias command displays information on configuring your environment:
35
35
  .
36
36
  .TP
37
- \fBhub alias\fR [\fB\-s\fR] \fISHELL\fR
38
- Writes shell aliasing code for \fISHELL\fR (\fBbash\fR, \fBsh\fR, \fBzsh\fR, \fBcsh\fR) to standard output. With the \fB\-s\fR option, the output of
39
- this command can be evaluated directly within the shell: \fBeval $(hub alias \-s bash)\fR
37
+ \fBhub alias\fR [\fB-s\fR] \fISHELL\fR
38
+ Writes shell aliasing code for \fISHELL\fR (\fBbash\fR, \fBsh\fR, \fBzsh\fR, \fBcsh\fR) to standard output. With the \fB-s\fR option, the output of
39
+ this command can be evaluated directly within the shell: \fBeval $(hub alias -s bash)\fR
40
40
  .
41
41
  .P
42
42
  After configuring the alias, the following commands have superpowers:
43
43
  .
44
44
  .TP
45
- \fBgit init\fR \fB\-g\fR \fIOPTIONS\fR
45
+ \fBgit init\fR \fB-g\fR \fIOPTIONS\fR
46
46
  Create a git repository as with git\-init(1) and add remote \fBorigin\fR at
47
47
  "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory's basename.
48
48
  .
49
49
  .TP
50
- \fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR
50
+ \fBgit clone\fR [\fB-p\fR] \fIOPTIONS\fR [\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR \fIDIRECTORY\fR
51
51
  Clone repository "git://github.com/\fIUSER\fR/\fIREPOSITORY\fR.git" into \fIDIRECTORY\fR as with git\-clone(1). When \fIUSER\fR/ is omitted, assumes
52
- your GitHub login. With \fB\-p\fR, use private remote
52
+ your GitHub login. With \fB-p\fR, use private remote
53
53
  "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git".
54
54
  .
55
55
  .TP
56
- \fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]
56
+ \fBgit remote add\fR [\fB-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]
57
57
  Add remote "git://github.com/\fIUSER\fR/\fIREPOSITORY\fR.git" as with
58
58
  git\-remote(1). When /\fIREPOSITORY\fR is omitted, the basename of the
59
- current working directory is used. With \fB\-p\fR, use private remote
59
+ current working directory is used. With \fB-p\fR, use private remote
60
60
  "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git". If \fIUSER\fR is "origin"
61
61
  then uses your GitHub login.
62
62
  .
@@ -66,16 +66,16 @@ Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing
66
66
  multiple \fBgit push\fR commands.
67
67
  .
68
68
  .TP
69
- \fBgit browse\fR [\fB\-p\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR]
69
+ \fBgit browse\fR [\fB-p\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR]
70
70
  Open repository's GitHub page in the system's default web browser
71
- using \fBopen(1)\fR or the \fBBROWSER\fR env variable. Use \fB\-p\fR to open a
71
+ using \fBopen(1)\fR or the \fBBROWSER\fR env variable. Use \fB-p\fR to open a
72
72
  page with https. If the repository isn't specified, \fBbrowse\fR opens
73
73
  the page of the repository found in the current directory.
74
74
  .
75
75
  .TP
76
- \fBgit submodule add\fR [\fB\-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
76
+ \fBgit submodule add\fR [\fB-p\fR] \fIOPTIONS\fR [\fIUSER\fR/]\fIREPOSITORY\fR \fIDIRECTORY\fR
77
77
  Submodule repository "git://github.com/\fIUSER\fR/\fIREPOSITORY\fR.git" into \fIDIRECTORY\fR as with git\-submodule(1). When \fIUSER\fR/ is omitted, assumes
78
- your GitHub login. With \fB\-p\fR, use private remote
78
+ your GitHub login. With \fB-p\fR, use private remote
79
79
  "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git".
80
80
  .
81
81
  .TP
@@ -89,7 +89,7 @@ Use git\-config(1) to display the currently configured GitHub username:
89
89
  .
90
90
  .nf
91
91
 
92
- $ git config \-\-global github.user
92
+ \fB$ git config --global github.user \fR
93
93
  .
94
94
  .fi
95
95
  .
@@ -102,7 +102,7 @@ Or, set the GitHub username with:
102
102
  .
103
103
  .nf
104
104
 
105
- $ git config \-\-global github.user <username>
105
+ \fB$ git config --global github.user <username> \fR
106
106
  .
107
107
  .fi
108
108
  .
@@ -120,7 +120,7 @@ cloning:
120
120
  .
121
121
  .nf
122
122
 
123
- $ git config \-\-global \-\-add hub.http\-clone yes
123
+ \fB$ git config --global --add hub.http-clone yes \fR
124
124
  .
125
125
  .fi
126
126
  .
@@ -132,16 +132,17 @@ $ git config \-\-global \-\-add hub.http\-clone yes
132
132
  .
133
133
  .nf
134
134
 
135
- $ git clone schacon/ticgit
135
+ \fB$ git clone schacon/ticgit
136
136
  > git clone git://github.com/schacon/ticgit.git
137
- $ git clone \-p schacon/ticgit
137
+ $ git clone -p schacon/ticgit
138
138
  > git clone git@github.com:schacon/ticgit.git
139
139
 
140
140
  $ git clone resque
141
141
  > git clone git://github.com/YOUR_USER/resque.git
142
142
 
143
- $ git clone \-p resque
143
+ $ git clone -p resque
144
144
  > git clone git@github.com:YOUR_USER/resque.git
145
+ \fR
145
146
  .
146
147
  .fi
147
148
  .
@@ -149,13 +150,14 @@ $ git clone \-p resque
149
150
  .
150
151
  .nf
151
152
 
152
- $ git remote add rtomayko
153
+ \fB$ git remote add rtomayko
153
154
  > git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git
154
- $ git remote add \-p rtomayko
155
+ $ git remote add -p rtomayko
155
156
  > git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git
156
157
 
157
158
  $ git remote add origin
158
159
  > git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git
160
+ \fR
159
161
  .
160
162
  .fi
161
163
  .
@@ -163,9 +165,9 @@ $ git remote add origin
163
165
  .
164
166
  .nf
165
167
 
166
- $ git init \-g
168
+ \fB$ git init -g
167
169
  > git init
168
- > git remote add origin git@github.com:YOUR_USER/REPO.git
170
+ > git remote add origin git@github.com:YOUR_USER/REPO.git \fR
169
171
  .
170
172
  .fi
171
173
  .
@@ -173,10 +175,10 @@ $ git init \-g
173
175
  .
174
176
  .nf
175
177
 
176
- $ git push origin,staging,qa bert_timeout
178
+ \fB$ git push origin,staging,qa bert_timeout
177
179
  > git push origin bert_timeout
178
180
  > git push staging bert_timeout
179
- > git push qa bert_timeout
181
+ > git push qa bert_timeout \fR
180
182
  .
181
183
  .fi
182
184
  .
@@ -184,16 +186,17 @@ $ git push origin,staging,qa bert_timeout
184
186
  .
185
187
  .nf
186
188
 
187
- $ git browse schacon/ticgit
189
+ \fB$ git browse schacon/ticgit
188
190
  > open http://github.com/schacon/ticgit
189
- $ git browse \-p schacon/ticgit
191
+ $ git browse -p schacon/ticgit
190
192
  > open http://github.com/schacon/ticgit
191
193
 
192
194
  $ git browse resque
193
195
  > open http://github.com/YOUR_USER/resque
194
196
 
195
- $ git browse \-p resque
197
+ $ git browse -p resque
196
198
  > open https://github.com:YOUR_USER/resque
199
+ \fR
197
200
  .
198
201
  .fi
199
202
  .
@@ -201,10 +204,10 @@ $ git browse \-p resque
201
204
  .
202
205
  .nf
203
206
 
204
- $ git help
207
+ \fB$ git help
205
208
  > (improved git help)
206
209
  $ git help hub
207
- > (hub man page)
210
+ > (hub man page) \fR
208
211
  .
209
212
  .fi
210
213
  .
data/test/hub_test.rb CHANGED
@@ -90,6 +90,18 @@ class HubTest < Test::Unit::TestCase
90
90
  assert_command input, command
91
91
  end
92
92
 
93
+ def test_public_remote_origin_as_normal
94
+ input = "remote add origin http://github.com/defunkt/resque.git"
95
+ command = "git remote add origin http://github.com/defunkt/resque.git"
96
+ assert_command input, command
97
+ end
98
+
99
+ def test_private_remote_origin_as_normal
100
+ input = "remote add origin git@github.com:defunkt/resque.git"
101
+ command = "git remote add origin git@github.com:defunkt/resque.git"
102
+ assert_command input, command
103
+ end
104
+
93
105
  def test_public_submodule
94
106
  input = "submodule add wycats/bundler vendor/bundler"
95
107
  command = "git submodule add git://github.com/wycats.bundler.git"
@@ -136,26 +148,26 @@ class HubTest < Test::Unit::TestCase
136
148
  end
137
149
 
138
150
  def test_private_remote_with_repo
139
- input = "remote add -p rtomayko/tilt"
140
- command = "git remote add rtomayko git@github.com:rtomayko/tilt.git"
151
+ input = "remote add -p jashkenas/coffee-script"
152
+ command = "git remote add jashkenas git@github.com:jashkenas/coffee-script.git"
141
153
  assert_command input, command
142
154
  end
143
155
 
144
156
  def test_public_remote_with_repo
145
- input = "remote add rtomayko/tilt"
146
- command = "git remote add rtomayko git://github.com/rtomayko/tilt.git"
157
+ input = "remote add jashkenas/coffee-script"
158
+ command = "git remote add jashkenas git://github.com/jashkenas/coffee-script.git"
147
159
  assert_command input, command
148
160
  end
149
161
 
150
162
  def test_public_remote_f_with_repo
151
- input = "remote add -f rtomayko/tilt"
152
- command = "git remote add -f rtomayko git://github.com/rtomayko/tilt.git"
163
+ input = "remote add -f jashkenas/coffee-script"
164
+ command = "git remote add -f jashkenas git://github.com/jashkenas/coffee-script.git"
153
165
  assert_command input, command
154
166
  end
155
167
 
156
168
  def test_named_private_remote_with_repo
157
- input = "remote add -p origin rtomayko/tilt"
158
- command = "git remote add origin git@github.com:rtomayko/tilt.git"
169
+ input = "remote add -p origin jashkenas/coffee-script"
170
+ command = "git remote add origin git@github.com:jashkenas/coffee-script.git"
159
171
  assert_command input, command
160
172
  end
161
173
 
@@ -206,7 +218,6 @@ class HubTest < Test::Unit::TestCase
206
218
  def test_help_hub
207
219
  help_manpage = hub("help hub")
208
220
  assert_includes "git + hub = github", help_manpage
209
- assert_includes "$ git clone schacon/ticgit", help_manpage
210
221
  assert_includes "Chris Wanstrath :: chris@ozmm.org", help_manpage
211
222
  assert_includes <<-config, help_manpage
212
223
  Use git-config(1) to display the currently configured GitHub username:
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: 1.0.2
4
+ version: 1.0.3
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: 2010-03-07 00:00:00 -08:00
12
+ date: 2010-03-10 00:00:00 -08:00
13
13
  default_executable: hub
14
14
  dependencies: []
15
15