git-hub 1.1.0 → 1.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/test/hub_test.rb CHANGED
@@ -5,22 +5,43 @@ require 'webmock/test_unit'
5
5
  class HubTest < Test::Unit::TestCase
6
6
  include WebMock
7
7
 
8
+ COMMANDS = []
9
+
10
+ Hub::Commands.class_eval do
11
+ remove_method :command?
12
+ define_method :command? do |name|
13
+ COMMANDS.include?(name)
14
+ end
15
+ end
16
+
8
17
  def setup
9
- Hub::Commands::REPO.replace("hub")
10
- Hub::Commands::USER.replace("tpw")
11
- Hub::Commands::TOKEN.replace("abc123")
12
- Hub::Commands::OWNER.replace("defunkt")
18
+ COMMANDS.replace %w[open groff]
19
+
20
+ @git = Hub::Context::GIT_CONFIG.replace(Hash.new { |h, k|
21
+ raise ArgumentError, "`git #{k}` not stubbed"
22
+ }).update(
23
+ 'symbolic-ref -q HEAD' => 'refs/heads/master',
24
+ 'config github.user' => 'tpw',
25
+ 'config github.token' => 'abc123',
26
+ 'config remote.origin.url' => 'git://github.com/defunkt/hub.git',
27
+ 'config remote.mislav.url' => 'git://github.com/mislav/hub.git',
28
+ 'config branch.master.remote' => 'origin',
29
+ 'config branch.master.merge' => 'refs/heads/master',
30
+ 'config branch.feature.remote' => 'mislav',
31
+ 'config branch.feature.merge' => 'refs/heads/experimental',
32
+ 'config --bool hub.http-clone' => 'false'
33
+ )
13
34
  end
14
35
 
15
36
  def test_private_clone
16
- input = "clone -p rtomayko/ron"
17
- command = "git clone git@github.com:rtomayko/ron.git"
37
+ input = "clone -p rtomayko/ronn"
38
+ command = "git clone git@github.com:rtomayko/ronn.git"
18
39
  assert_command input, command
19
40
  end
20
41
 
21
42
  def test_public_clone
22
- input = "clone rtomayko/ron"
23
- command = "git clone git://github.com/rtomayko/ron.git"
43
+ input = "clone rtomayko/ronn"
44
+ command = "git clone git://github.com/rtomayko/ronn.git"
24
45
  assert_command input, command
25
46
  end
26
47
 
@@ -44,7 +65,7 @@ class HubTest < Test::Unit::TestCase
44
65
 
45
66
  def test_your_private_clone_fails_without_config
46
67
  out = hub("clone -p mustache") do
47
- Hub::Commands::USER.replace("")
68
+ stub_github_user(nil)
48
69
  end
49
70
 
50
71
  assert_equal "** No GitHub user set. See http://github.com/guides/local-github-config\n", out
@@ -52,27 +73,27 @@ class HubTest < Test::Unit::TestCase
52
73
 
53
74
  def test_your_public_clone_fails_without_config
54
75
  out = hub("clone mustache") do
55
- Hub::Commands::USER.replace("")
76
+ stub_github_user(nil)
56
77
  end
57
78
 
58
79
  assert_equal "** No GitHub user set. See http://github.com/guides/local-github-config\n", out
59
80
  end
60
81
 
61
82
  def test_private_clone_left_alone
62
- input = "clone git@github.com:rtomayko/ron.git"
63
- command = "git clone git@github.com:rtomayko/ron.git"
83
+ input = "clone git@github.com:rtomayko/ronn.git"
84
+ command = "git clone git@github.com:rtomayko/ronn.git"
64
85
  assert_command input, command
65
86
  end
66
87
 
67
88
  def test_public_clone_left_alone
68
- input = "clone git://github.com/rtomayko/ron.git"
69
- command = "git clone git://github.com/rtomayko/ron.git"
89
+ input = "clone git://github.com/rtomayko/ronn.git"
90
+ command = "git clone git://github.com/rtomayko/ronn.git"
70
91
  assert_command input, command
71
92
  end
72
93
 
73
94
  def test_normal_public_clone_with_path
74
- input = "clone git://github.com/rtomayko/ron.git ron-dev"
75
- command = "git clone git://github.com/rtomayko/ron.git ron-dev"
95
+ input = "clone git://github.com/rtomayko/ronn.git ronn-dev"
96
+ command = "git clone git://github.com/rtomayko/ronn.git ronn-dev"
76
97
  assert_command input, command
77
98
  end
78
99
 
@@ -100,6 +121,18 @@ class HubTest < Test::Unit::TestCase
100
121
  assert_command input, command
101
122
  end
102
123
 
124
+ def test_remote_from_rel_path
125
+ input = "remote add origin ./path"
126
+ command = "git remote add origin ./path"
127
+ assert_command input, command
128
+ end
129
+
130
+ def test_remote_from_abs_path
131
+ input = "remote add origin /path"
132
+ command = "git remote add origin /path"
133
+ assert_command input, command
134
+ end
135
+
103
136
  def test_private_remote_origin_as_normal
104
137
  input = "remote add origin git@github.com:defunkt/resque.git"
105
138
  command = "git remote add origin git@github.com:defunkt/resque.git"
@@ -108,17 +141,26 @@ class HubTest < Test::Unit::TestCase
108
141
 
109
142
  def test_public_submodule
110
143
  input = "submodule add wycats/bundler vendor/bundler"
111
- command = "git submodule add git://github.com/wycats.bundler.git"
144
+ command = "git submodule add git://github.com/wycats/bundler.git vendor/bundler"
145
+ assert_command input, command
112
146
  end
113
147
 
114
148
  def test_private_submodule
115
149
  input = "submodule add -p grit vendor/grit"
116
- command = "git submodule add git@github.com:tpw/grit.git"
150
+ command = "git submodule add git@github.com:tpw/grit.git vendor/grit"
151
+ assert_command input, command
152
+ end
153
+
154
+ def test_submodule_branch
155
+ input = "submodule add -b ryppl ryppl/pip vendor/pip"
156
+ command = "git submodule add -b ryppl git://github.com/ryppl/pip.git vendor/pip"
157
+ assert_command input, command
117
158
  end
118
159
 
119
160
  def test_submodule_with_args
120
161
  input = "submodule -q add --bare -- grit grit"
121
162
  command = "git submodule -q add --bare -- git://github.com/tpw/grit.git grit"
163
+ assert_command input, command
122
164
  end
123
165
 
124
166
  def test_private_remote
@@ -183,7 +225,7 @@ class HubTest < Test::Unit::TestCase
183
225
 
184
226
  def test_init_no_login
185
227
  out = hub("init -g") do
186
- Hub::Commands::USER.replace("")
228
+ stub_github_user(nil)
187
229
  end
188
230
 
189
231
  assert_equal "** No GitHub user set. See http://github.com/guides/local-github-config\n", out
@@ -234,7 +276,7 @@ class HubTest < Test::Unit::TestCase
234
276
 
235
277
  def test_version
236
278
  out = hub('--version')
237
- assert_includes "git version", out
279
+ assert_includes "git version 1.7.0.4", out
238
280
  assert_includes "hub version #{Hub::Version}", out
239
281
  end
240
282
 
@@ -260,13 +302,8 @@ config
260
302
  end
261
303
 
262
304
  def test_help_hub_no_groff
263
- help_manpage = hub("help hub") do
264
- Hub::Commands.class_eval do
265
- remove_method :groff?
266
- def groff?; false end
267
- end
268
- end
269
- assert_equal "** Can't find groff(1)\n", help_manpage
305
+ stub_available_commands()
306
+ assert_equal "** Can't find groff(1)\n", hub("help hub")
270
307
  end
271
308
 
272
309
  def test_hub_standalone
@@ -274,34 +311,197 @@ config
274
311
  assert_equal Hub::Standalone.build, help_standalone
275
312
  end
276
313
 
277
- def test_hub_open
314
+ def test_hub_compare
315
+ assert_command "compare refactor",
316
+ "open http://github.com/defunkt/hub/compare/refactor"
317
+ end
318
+
319
+ def test_hub_compare_nothing
320
+ expected = "Usage: hub compare [USER] [<START>...]<END>\n"
321
+ assert_equal expected, hub("compare")
322
+ end
323
+
324
+ def test_hub_compare_tracking_nothing
325
+ stub_tracking_nothing
326
+ expected = "Usage: hub compare [USER] [<START>...]<END>\n"
327
+ assert_equal expected, hub("compare")
328
+ end
329
+
330
+ def test_hub_compare_tracking_branch
331
+ stub_branch('refs/heads/feature')
332
+
333
+ assert_command "compare",
334
+ "open http://github.com/mislav/hub/compare/experimental"
335
+ end
336
+
337
+ def test_hub_compare_range
338
+ assert_command "compare 1.0...fix",
339
+ "open http://github.com/defunkt/hub/compare/1.0...fix"
340
+ end
341
+
342
+ def test_hub_compare_fork
343
+ assert_command "compare myfork feature",
344
+ "open http://github.com/myfork/hub/compare/feature"
345
+ end
346
+
347
+ def test_hub_compare_private
348
+ assert_command "compare -p myfork topsecret",
349
+ "open https://github.com/myfork/hub/compare/topsecret"
350
+ end
351
+
352
+ def test_hub_compare_url
353
+ assert_command "compare -u 1.0...1.1",
354
+ "echo http://github.com/defunkt/hub/compare/1.0...1.1"
355
+ end
356
+
357
+ def test_hub_browse
358
+ assert_command "browse mojombo/bert", "open http://github.com/mojombo/bert"
359
+ end
360
+
361
+ def test_hub_browse_tracking_nothing
362
+ stub_tracking_nothing
278
363
  assert_command "browse mojombo/bert", "open http://github.com/mojombo/bert"
279
364
  end
280
365
 
281
- def test_hub_open_private
366
+ def test_hub_browse_url
367
+ assert_command "browse -u mojombo/bert", "echo http://github.com/mojombo/bert"
368
+ end
369
+
370
+ def test_hub_browse_private
282
371
  assert_command "browse -p bmizerany/sinatra",
283
372
  "open https://github.com/bmizerany/sinatra"
284
373
  end
285
374
 
286
- def test_hub_open_self
375
+ def test_hub_browse_self
376
+ assert_command "browse resque", "open http://github.com/tpw/resque"
377
+ end
378
+
379
+ def test_hub_browse_subpage
380
+ assert_command "browse resque commits",
381
+ "open http://github.com/tpw/resque/commits/master"
382
+ assert_command "browse resque issues",
383
+ "open http://github.com/tpw/resque/issues"
384
+ assert_command "browse resque wiki",
385
+ "open http://wiki.github.com/tpw/resque/"
386
+ end
387
+
388
+ def test_hub_browse_on_branch
389
+ stub_branch('refs/heads/feature')
390
+
287
391
  assert_command "browse resque", "open http://github.com/tpw/resque"
392
+ assert_command "browse resque commits",
393
+ "open http://github.com/tpw/resque/commits/master"
394
+
395
+ assert_command "browse",
396
+ "open http://github.com/mislav/hub/tree/experimental"
397
+ assert_command "browse -- tree",
398
+ "open http://github.com/mislav/hub/tree/experimental"
399
+ assert_command "browse -- commits",
400
+ "open http://github.com/mislav/hub/commits/experimental"
288
401
  end
289
402
 
290
- def test_hub_open_self_private
403
+ def test_hub_browse_self_private
291
404
  assert_command "browse -p github", "open https://github.com/tpw/github"
292
405
  end
293
406
 
294
- def test_hub_open_current
407
+ def test_hub_browse_current
295
408
  assert_command "browse", "open http://github.com/defunkt/hub"
409
+ assert_command "browse --", "open http://github.com/defunkt/hub"
296
410
  end
297
411
 
298
- def test_hub_open_current_private
412
+ def test_hub_browse_current_subpage
413
+ assert_command "browse -- network",
414
+ "open http://github.com/defunkt/hub/network"
415
+ assert_command "browse -- anything/everything",
416
+ "open http://github.com/defunkt/hub/anything/everything"
417
+ end
418
+
419
+ def test_hub_browse_current_private
299
420
  assert_command "browse -p", "open https://github.com/defunkt/hub"
300
421
  end
301
422
 
302
- def test_hub_open_no_repo
303
- Hub::Commands::OWNER.replace("")
304
- input = "browse"
305
- assert_equal "Usage: hub browse [<USER>/]<REPOSITORY>\n", hub(input)
423
+ def test_hub_browse_no_repo
424
+ stub_repo_url(nil)
425
+ assert_equal "Usage: hub browse [<USER>/]<REPOSITORY>\n", hub("browse")
426
+ end
427
+
428
+ def test_custom_browser
429
+ with_browser_env("custom") do
430
+ assert_browser("custom")
431
+ end
306
432
  end
433
+
434
+ def test_linux_browser
435
+ stub_available_commands "open", "xdg-open", "cygstart"
436
+ with_browser_env(nil) do
437
+ with_ruby_platform("i686-linux") do
438
+ assert_browser("xdg-open")
439
+ end
440
+ end
441
+ end
442
+
443
+ def test_cygwin_browser
444
+ stub_available_commands "open", "cygstart"
445
+ with_browser_env(nil) do
446
+ with_ruby_platform("i686-linux") do
447
+ assert_browser("cygstart")
448
+ end
449
+ end
450
+ end
451
+
452
+ def test_no_browser
453
+ stub_available_commands()
454
+ expected = "Please set $BROWSER to a web launcher to use this command.\n"
455
+ with_browser_env(nil) do
456
+ with_ruby_platform("i686-linux") do
457
+ assert_equal expected, hub("browse")
458
+ end
459
+ end
460
+ end
461
+
462
+ protected
463
+
464
+ def stub_github_user(name)
465
+ @git['config github.user'] = name
466
+ end
467
+
468
+ def stub_repo_url(value)
469
+ @git['config remote.origin.url'] = value
470
+ Hub::Context::REMOTES.clear
471
+ end
472
+
473
+ def stub_branch(value)
474
+ @git['symbolic-ref -q HEAD'] = value
475
+ end
476
+
477
+ def stub_tracking_nothing
478
+ @git['config branch.master.remote'] = nil
479
+ @git['config branch.master.merge'] = nil
480
+ end
481
+
482
+ def stub_available_commands(*names)
483
+ COMMANDS.replace names
484
+ end
485
+
486
+ def with_browser_env(value)
487
+ browser, ENV['BROWSER'] = ENV['BROWSER'], value
488
+ yield
489
+ ensure
490
+ ENV['BROWSER'] = browser
491
+ end
492
+
493
+ def assert_browser(browser)
494
+ assert_command "browse", "#{browser} http://github.com/defunkt/hub"
495
+ end
496
+
497
+ def with_ruby_platform(value)
498
+ platform = RUBY_PLATFORM
499
+ Object.send(:remove_const, :RUBY_PLATFORM)
500
+ Object.const_set(:RUBY_PLATFORM, value)
501
+ yield
502
+ ensure
503
+ Object.send(:remove_const, :RUBY_PLATFORM)
504
+ Object.const_set(:RUBY_PLATFORM, platform)
505
+ end
506
+
307
507
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 3
8
+ - 0
9
+ version: 1.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Chris Wanstrath
@@ -9,38 +14,36 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-04-07 00:00:00 -07:00
13
- default_executable: hub
17
+ date: 2010-04-29 00:00:00 -07:00
18
+ default_executable:
14
19
  dependencies: []
15
20
 
16
- description: hub introduces git to GitHub
21
+ description: " `hub` is a command line utility which adds GitHub knowledge to `git`.\n\n It can used on its own or as a `git` wrapper.\n\n Normal:\n\n $ hub clone rtomayko/tilt\n\n Expands to:\n $ git clone git://github.com/rtomayko/tilt.git\n\n Wrapping `git`:\n\n $ git clone rack/rack\n\n Expands to:\n $ git clone git://github.com/rack/rack.git\n"
17
22
  email: chris@ozmm.org
18
23
  executables:
19
24
  - hub
20
25
  extensions: []
21
26
 
22
- extra_rdoc_files:
23
- - LICENSE
24
- - README.md
27
+ extra_rdoc_files: []
28
+
25
29
  files:
26
- - .gitignore
27
- - .kick
28
- - CONTRIBUTORS
29
- - HISTORY.md
30
- - LICENSE
31
30
  - README.md
32
31
  - Rakefile
33
- - bin/hub
34
- - lib/hub.rb
32
+ - LICENSE
35
33
  - lib/hub/args.rb
36
34
  - lib/hub/commands.rb
35
+ - lib/hub/context.rb
37
36
  - lib/hub/runner.rb
38
37
  - lib/hub/standalone.rb
39
38
  - lib/hub/version.rb
39
+ - lib/hub.rb
40
+ - bin/hub
40
41
  - man/hub.1
41
42
  - man/hub.1.html
42
- - man/hub.1.ron
43
+ - man/hub.1.ronn
43
44
  - test/alias_test.rb
45
+ - test/fakebin/git
46
+ - test/fakebin/open
44
47
  - test/helper.rb
45
48
  - test/hub_test.rb
46
49
  - test/standalone_test.rb
@@ -68,31 +71,30 @@ post_install_message: |+
68
71
 
69
72
  ------------------------------------------------------------
70
73
 
71
- rdoc_options:
72
- - --charset=UTF-8
74
+ rdoc_options: []
75
+
73
76
  require_paths:
74
77
  - lib
75
78
  required_ruby_version: !ruby/object:Gem::Requirement
76
79
  requirements:
77
80
  - - ">="
78
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
79
84
  version: "0"
80
- version:
81
85
  required_rubygems_version: !ruby/object:Gem::Requirement
82
86
  requirements:
83
87
  - - ">="
84
88
  - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
85
91
  version: "0"
86
- version:
87
92
  requirements: []
88
93
 
89
94
  rubyforge_project:
90
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.6
91
96
  signing_key:
92
97
  specification_version: 3
93
98
  summary: hub introduces git to GitHub
94
- test_files:
95
- - test/alias_test.rb
96
- - test/helper.rb
97
- - test/hub_test.rb
98
- - test/standalone_test.rb
99
+ test_files: []
100
+
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.swp
2
- *~
data/.kick DELETED
@@ -1,26 +0,0 @@
1
- # take control of the growl notifications
2
- module GrowlHacks
3
- def growl(type, subject, body, *args, &block)
4
- case type
5
- when Kicker::GROWL_NOTIFICATIONS[:succeeded]
6
- puts subject = "Success"
7
- body = body.split("\n").last
8
- when Kicker::GROWL_NOTIFICATIONS[:failed]
9
- subject = "Failure"
10
- puts body
11
- body = body.split("\n").last
12
- else
13
- return nil
14
- end
15
- super(type, subject, body, *args, &block)
16
- end
17
- end
18
-
19
- Kicker.send :extend, GrowlHacks
20
-
21
- # no logging
22
- Kicker::Utils.module_eval do
23
- def log(message)
24
- nil
25
- end
26
- end
data/CONTRIBUTORS DELETED
@@ -1,11 +0,0 @@
1
- * Chris Wanstrath
2
- * Stephen Celis
3
- * Rob Ares
4
- * Mislav Marohnić
5
- * Ryan Tomayko
6
- * Caio Chassot
7
- * Joshua Peek
8
- * Nick Quaranto
9
- * Konstantin Haase
10
- * Scott Chacon
11
- * Alex Kahn
data/HISTORY.md DELETED
@@ -1,75 +0,0 @@
1
- ## 1.1.0 (2010-04-07)
2
-
3
- * `hub fork` command - Thanks Mislav!
4
-
5
- ## 1.0.3 (2010-03-10)
6
-
7
- * Bugfix: `hub remote` for repos with -, /, etc
8
-
9
- ## 1.0.2 (2010-03-07)
10
-
11
- * Bugfix: `hub remote -f name` (for real this time)
12
- * Bugfix: zsh quoting [thommay]
13
-
14
- ## 1.0.1 (2010-03-05)
15
-
16
- * Bugfix: `hub remote -f name`
17
-
18
- ## 1.0.0 (2010-03-03)
19
-
20
- * `hub browse` with no arguments uses the current repo.
21
- * `hub submodule add user/repo directory
22
- * `hub remote add rtomayko/tilt`
23
- * `remote add -p origin rtomayko/tilt`
24
-
25
- ## 0.3.2 (2010-02-17)
26
-
27
- * Fixed zshell git completion / aliasing - `hub alias zsh`.
28
-
29
- ## 0.3.1 (2010-02-13)
30
-
31
- * Add `hub remote origin` shortcut. Assumes your GitHub login.
32
-
33
- ## 0.3.0 (2010-01-23)
34
-
35
- * Add `hub browse` command for opening a repo in a browser.
36
- * Add `hub standalone` for installation of standalone via RubyGems
37
- * Bugfix: Don't run hub standalone in standalone mode
38
- * Bugfix: `git clone` flags are now passed through.
39
- * Bugfix: `git clone` with url and path works.
40
- * Bugfix: basename call
41
- * Bugfix: Check for local directories before cloning
42
-
43
-
44
- ## 0.2.0 (2009-12-24)
45
-
46
- * Respected GIT_PAGER and core.pager
47
- * Aliased `--help` to `help`
48
- * Ruby 1.9 fixes
49
- * Respect git behavior when pager is empty string
50
- * `git push` multi-remote support
51
- * `hub.http-clone` configuration setting
52
- * Use the origin url to find the repo name
53
-
54
- ## 0.1.3 (2009-12-11)
55
-
56
- * Homebrew!
57
- * Fix inaccuracy in man page
58
- * Better help arrangement
59
- * Bugfix: Path problems in standalone.rb
60
- * Bugfix: Standalone not loaded by default
61
-
62
- ## 0.1.2 (2009-12-10)
63
-
64
- * Fixed README typos
65
- * Better standalone install line
66
- * Added man page
67
- * Added `hub help hub`
68
-
69
- ## 0.1.1 (2009-12-08)
70
-
71
- * Fixed gem problems
72
-
73
- ## 0.1.0 (2009-12-08)
74
-
75
- * First release