hub 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of hub might be problematic. Click here for more details.
- data/README.md +1 -1
- data/lib/hub/args.rb +6 -1
- data/lib/hub/commands.rb +49 -33
- data/lib/hub/context.rb +59 -9
- data/lib/hub/version.rb +1 -1
- data/man/hub.1 +3 -3
- data/man/hub.1.html +4 -4
- data/man/hub.1.ronn +2 -2
- data/test/fakebin/git +1 -1
- data/test/hub_test.rb +58 -24
- metadata +31 -62
data/README.md
CHANGED
data/lib/hub/args.rb
CHANGED
@@ -54,7 +54,7 @@ module Hub
|
|
54
54
|
# Array of `executable` followed by all args suitable as arguments
|
55
55
|
# for `exec` or `system` calls.
|
56
56
|
def to_exec(args = self)
|
57
|
-
|
57
|
+
Array(executable) + args
|
58
58
|
end
|
59
59
|
|
60
60
|
# All the words (as opposed to flags) contained in this argument
|
@@ -80,6 +80,11 @@ module Hub
|
|
80
80
|
chained? or self != @original_args
|
81
81
|
end
|
82
82
|
|
83
|
+
def has_flag?(*flags)
|
84
|
+
pattern = flags.flatten.map { |f| Regexp.escape(f) }.join('|')
|
85
|
+
!grep(/^#{pattern}(?:=|$)/).empty?
|
86
|
+
end
|
87
|
+
|
83
88
|
private
|
84
89
|
|
85
90
|
def normalize_callback(cmd_or_args, args, block)
|
data/lib/hub/commands.rb
CHANGED
@@ -42,8 +42,10 @@ module Hub
|
|
42
42
|
API_CREATE = 'http://github.com/api/v2/yaml/repos/create'
|
43
43
|
|
44
44
|
def run(args)
|
45
|
+
slurp_global_flags(args)
|
46
|
+
|
45
47
|
# Hack to emulate git-style
|
46
|
-
args.unshift 'help' if args.
|
48
|
+
args.unshift 'help' if args.empty?
|
47
49
|
|
48
50
|
cmd = args[0]
|
49
51
|
expanded_args = expand_alias(cmd)
|
@@ -334,9 +336,9 @@ module Hub
|
|
334
336
|
# > git push origin cool-feature
|
335
337
|
# > git push staging cool-feature
|
336
338
|
def push(args)
|
337
|
-
return
|
339
|
+
return if args[1].nil? || !args[1].index(',')
|
338
340
|
|
339
|
-
branch = args[2]
|
341
|
+
branch = (args[2] ||= normalize_branch(current_branch))
|
340
342
|
remotes = args[1].split(',')
|
341
343
|
args[1] = remotes.shift
|
342
344
|
|
@@ -493,13 +495,13 @@ module Hub
|
|
493
495
|
# $ hub help
|
494
496
|
# (print improved help text)
|
495
497
|
def help(args)
|
496
|
-
command = args.
|
498
|
+
command = args.words[1]
|
497
499
|
|
498
500
|
if command == 'hub'
|
499
501
|
puts hub_manpage
|
500
502
|
exit
|
501
|
-
elsif command.nil? && args.
|
502
|
-
ENV['GIT_PAGER'] = ''
|
503
|
+
elsif command.nil? && !args.has_flag?('-a', '--all')
|
504
|
+
ENV['GIT_PAGER'] = '' unless args.has_flag?('-p', '--paginate') # Use `cat`.
|
503
505
|
puts improved_help_text
|
504
506
|
exit
|
505
507
|
end
|
@@ -556,33 +558,48 @@ help
|
|
556
558
|
# from the command line.
|
557
559
|
#
|
558
560
|
|
559
|
-
#
|
561
|
+
# Extract global flags from the front of the arguments list.
|
562
|
+
# Makes sure important ones are supplied for calls to subcommands.
|
560
563
|
#
|
561
|
-
#
|
564
|
+
# Known flags are:
|
565
|
+
# --version --exec-path=<path> --html-path
|
566
|
+
# -p|--paginate|--no-pager --no-replace-objects
|
567
|
+
# --bare --git-dir=<path> --work-tree=<path>
|
568
|
+
# -c name=value --help
|
562
569
|
#
|
563
|
-
#
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
570
|
+
# Special: `--version`, `--help` are replaced with "version" and "help".
|
571
|
+
# Ignored: `--exec-path`, `--html-path` are kept in args list untouched.
|
572
|
+
def slurp_global_flags(args)
|
573
|
+
flags = %w[ -c -p --paginate --no-pager --no-replace-objects --bare --version --help ]
|
574
|
+
flags2 = %w[ --exec-path= --git-dir= --work-tree= ]
|
575
|
+
|
576
|
+
# flags that should be present in subcommands, too
|
577
|
+
globals = []
|
578
|
+
# flags that apply only to main command
|
579
|
+
locals = []
|
580
|
+
|
581
|
+
while args[0] && (flags.include?(args[0]) || flags2.any? {|f| args[0].index(f) == 0 })
|
582
|
+
flag = args.shift
|
583
|
+
case flag
|
584
|
+
when '--version', '--help'
|
585
|
+
args.unshift flag.sub('--', '')
|
586
|
+
when '-c'
|
587
|
+
# slurp one additional argument
|
588
|
+
config_pair = args.shift
|
589
|
+
# add configuration to our local cache
|
590
|
+
key, value = config_pair.split('=', 2)
|
591
|
+
Context::GIT_CONFIG["config #{key}"] = value.to_s
|
592
|
+
|
593
|
+
globals << flag << config_pair
|
594
|
+
when '-p', '--paginate', '--no-pager'
|
595
|
+
locals << flag
|
596
|
+
else
|
597
|
+
globals << flag
|
598
|
+
end
|
585
599
|
end
|
600
|
+
|
601
|
+
Context::GIT_CONFIG.executable = Array(Context::GIT_CONFIG.executable).concat(globals)
|
602
|
+
args.executable = Array(args.executable).concat(globals).concat(locals)
|
586
603
|
end
|
587
604
|
|
588
605
|
# Handles common functionality of browser commands like `browse`
|
@@ -596,7 +613,6 @@ help
|
|
596
613
|
args.push github_url({:web => true, :private => true}.update(params))
|
597
614
|
end
|
598
615
|
|
599
|
-
|
600
616
|
# Returns the terminal-formatted manpage, ready to be printed to
|
601
617
|
# the screen.
|
602
618
|
def hub_manpage
|
@@ -708,8 +724,8 @@ help
|
|
708
724
|
def expand_alias(cmd)
|
709
725
|
if expanded = git_alias_for(cmd)
|
710
726
|
if expanded.index('!') != 0
|
711
|
-
require 'shellwords' unless
|
712
|
-
expanded
|
727
|
+
require 'shellwords' unless defined?(::Shellwords)
|
728
|
+
Shellwords.shellwords(expanded)
|
713
729
|
end
|
714
730
|
end
|
715
731
|
end
|
data/lib/hub/context.rb
CHANGED
@@ -1,12 +1,30 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module Hub
|
2
4
|
# Provides methods for inspecting the environment, such as GitHub user/token
|
3
5
|
# settings, repository info, and similar.
|
4
6
|
module Context
|
5
7
|
private
|
6
8
|
|
9
|
+
class ShellOutCache < Hash
|
10
|
+
attr_accessor :executable
|
11
|
+
|
12
|
+
def initialize(executable = nil, &block)
|
13
|
+
super(&block)
|
14
|
+
@executable = executable
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_exec(args)
|
18
|
+
args = Shellwords.shellwords(args) if args.respond_to? :to_str
|
19
|
+
Array(executable) + Array(args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
7
23
|
# Caches output when shelling out to git
|
8
|
-
GIT_CONFIG =
|
9
|
-
|
24
|
+
GIT_CONFIG = ShellOutCache.new(ENV['GIT'] || 'git') do |cache, cmd|
|
25
|
+
full_cmd = cache.to_exec(cmd)
|
26
|
+
cmd_string = full_cmd.respond_to?(:shelljoin) ? full_cmd.shelljoin : full_cmd.join(' ')
|
27
|
+
result = %x{#{cmd_string}}.chomp
|
10
28
|
cache[cmd] = $?.success? && !result.empty? ? result : nil
|
11
29
|
end
|
12
30
|
|
@@ -25,7 +43,7 @@ module Hub
|
|
25
43
|
end
|
26
44
|
end
|
27
45
|
|
28
|
-
LGHCONF = "http://github.com/
|
46
|
+
LGHCONF = "http://help.github.com/git-email-settings/"
|
29
47
|
|
30
48
|
def repo_owner
|
31
49
|
REMOTES[default_remote][:user]
|
@@ -78,12 +96,7 @@ module Hub
|
|
78
96
|
|
79
97
|
def current_remote
|
80
98
|
return if remotes.empty?
|
81
|
-
|
82
|
-
if current_branch
|
83
|
-
remote_for(current_branch)
|
84
|
-
else
|
85
|
-
default_remote
|
86
|
-
end
|
99
|
+
(current_branch && remote_for(current_branch)) || default_remote
|
87
100
|
end
|
88
101
|
|
89
102
|
def default_remote
|
@@ -155,5 +168,42 @@ module Hub
|
|
155
168
|
def current_dirname
|
156
169
|
DIRNAME
|
157
170
|
end
|
171
|
+
|
172
|
+
# Cross-platform web browser command; respects the value set in $BROWSER.
|
173
|
+
#
|
174
|
+
# Returns an array, e.g.: ['open']
|
175
|
+
def browser_launcher
|
176
|
+
require 'rbconfig'
|
177
|
+
browser = ENV['BROWSER'] ||
|
178
|
+
(RbConfig::CONFIG['host_os'].include?('darwin') && 'open') ||
|
179
|
+
(RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw|windows/ && 'start') ||
|
180
|
+
%w[xdg-open cygstart x-www-browser firefox opera mozilla netscape].find { |comm| which comm }
|
181
|
+
|
182
|
+
abort "Please set $BROWSER to a web launcher to use this command." unless browser
|
183
|
+
Array(browser)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Cross-platform way of finding an executable in the $PATH.
|
187
|
+
#
|
188
|
+
# which('ruby') #=> /usr/bin/ruby
|
189
|
+
def which(cmd)
|
190
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
191
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
192
|
+
exts.each { |ext|
|
193
|
+
exe = "#{path}/#{cmd}#{ext}"
|
194
|
+
return exe if File.executable? exe
|
195
|
+
}
|
196
|
+
end
|
197
|
+
return nil
|
198
|
+
end
|
199
|
+
|
200
|
+
# Checks whether a command exists on this system in the $PATH.
|
201
|
+
#
|
202
|
+
# name - The String name of the command to check for.
|
203
|
+
#
|
204
|
+
# Returns a Boolean.
|
205
|
+
def command?(name)
|
206
|
+
!which(name).nil?
|
207
|
+
end
|
158
208
|
end
|
159
209
|
end
|
data/lib/hub/version.rb
CHANGED
data/man/hub.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "HUB" "1" "
|
4
|
+
.TH "HUB" "1" "May 2011" "DEFUNKT" "Git Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBhub\fR \- git + hub = github
|
@@ -37,7 +37,7 @@
|
|
37
37
|
\fBgit am\fR \fIGITHUB\-URL\fR
|
38
38
|
.
|
39
39
|
.br
|
40
|
-
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR \fIREF\fR
|
40
|
+
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR [\fIREF\fR]
|
41
41
|
.
|
42
42
|
.br
|
43
43
|
\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
|
@@ -97,7 +97,7 @@ Sets the url of remote \fIREMOTE\-NAME\fR using the same rules as \fBgit remote
|
|
97
97
|
\fBgit am\fR \fIGITHUB\-URL\fR: Downloads the patch file for the pull request or commit at the URL and applies that patch from disk with \fBgit am\fR\. Similar to \fBcherry\-pick\fR, but doesn\'t add new remotes\.
|
98
98
|
.
|
99
99
|
.IP "\(bu" 4
|
100
|
-
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR \fIREF\fR: Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing multiple \fBgit push\fR commands\.
|
100
|
+
\fBgit push\fR \fIREMOTE\-1\fR,\fIREMOTE\-2\fR,\.\.\.,\fIREMOTE\-N\fR [\fIREF\fR]: Push \fIREF\fR to each of \fIREMOTE\-1\fR through \fIREMOTE\-N\fR by executing multiple \fBgit push\fR commands\.
|
101
101
|
.
|
102
102
|
.IP "\(bu" 4
|
103
103
|
\fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]: Open repository\'s GitHub page in the system\'s default web browser using \fBopen(1)\fR or the \fBBROWSER\fR env variable\. If the repository isn\'t specified, \fBbrowse\fR opens the page of the repository found in the current directory\. If SUBPAGE is specified, the browser will open on the specified subpage: one of "wiki", "commits", "issues" or other (the default is "tree")\.
|
data/man/hub.1.html
CHANGED
@@ -61,7 +61,7 @@
|
|
61
61
|
<a href="#BUGS">BUGS</a>
|
62
62
|
<a href="#AUTHORS">AUTHORS</a>
|
63
63
|
<a href="#SEE-ALSO">SEE ALSO</a>
|
64
|
-
|
64
|
+
</div>
|
65
65
|
|
66
66
|
<ol class='man-decor man-head man head'>
|
67
67
|
<li class='tl'>hub(1)</li>
|
@@ -87,7 +87,7 @@
|
|
87
87
|
<code>git fetch</code> <var>USER-1</var>,[<var>USER-2</var>,...]<br />
|
88
88
|
<code>git cherry-pick</code> <var>GITHUB-REF</var><br />
|
89
89
|
<code>git am</code> <var>GITHUB-URL</var><br />
|
90
|
-
<code>git push</code> <var>REMOTE-1</var>,<var>REMOTE-2</var>,...,<var>REMOTE-N</var> <var>REF</var
|
90
|
+
<code>git push</code> <var>REMOTE-1</var>,<var>REMOTE-2</var>,...,<var>REMOTE-N</var> [<var>REF</var>]<br />
|
91
91
|
<code>git browse</code> [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>] [SUBPAGE]<br />
|
92
92
|
<code>git compare</code> [<code>-u</code>] [<var>USER</var>] [<var>START</var>...]<var>END</var><br />
|
93
93
|
<code>git submodule add</code> [<code>-p</code>] <var>OPTIONS</var> [<var>USER</var>/]<var>REPOSITORY</var> <var>DIRECTORY</var><br />
|
@@ -141,7 +141,7 @@ prior to the cherry-pick attempt.</p></li>
|
|
141
141
|
Downloads the patch file for the pull request or commit at the URL and
|
142
142
|
applies that patch from disk with <code>git am</code>. Similar to <code>cherry-pick</code>, but
|
143
143
|
doesn't add new remotes.</p></li>
|
144
|
-
<li><p><code>git push</code> <var>REMOTE-1</var>,<var>REMOTE-2</var>,...,<var>REMOTE-N</var> <var>REF</var
|
144
|
+
<li><p><code>git push</code> <var>REMOTE-1</var>,<var>REMOTE-2</var>,...,<var>REMOTE-N</var> [<var>REF</var>]:
|
145
145
|
Push <var>REF</var> to each of <var>REMOTE-1</var> through <var>REMOTE-N</var> by executing
|
146
146
|
multiple <code>git push</code> commands.</p></li>
|
147
147
|
<li><p><code>git browse</code> [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>] [SUBPAGE]:
|
@@ -361,7 +361,7 @@ $ git help hub
|
|
361
361
|
|
362
362
|
<ol class='man-decor man-foot man foot'>
|
363
363
|
<li class='tl'>DEFUNKT</li>
|
364
|
-
<li class='tc'>
|
364
|
+
<li class='tc'>May 2011</li>
|
365
365
|
<li class='tr'>hub(1)</li>
|
366
366
|
</ol>
|
367
367
|
|
data/man/hub.1.ronn
CHANGED
@@ -14,7 +14,7 @@ hub(1) -- git + hub = github
|
|
14
14
|
`git fetch` <USER-1>,[<USER-2>,...]
|
15
15
|
`git cherry-pick` <GITHUB-REF>
|
16
16
|
`git am` <GITHUB-URL>
|
17
|
-
`git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> <REF>
|
17
|
+
`git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]
|
18
18
|
`git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]
|
19
19
|
`git compare` [`-u`] [<USER>] [<START>...]<END>
|
20
20
|
`git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>
|
@@ -76,7 +76,7 @@ alias command displays information on configuring your environment:
|
|
76
76
|
applies that patch from disk with `git am`. Similar to `cherry-pick`, but
|
77
77
|
doesn't add new remotes.
|
78
78
|
|
79
|
-
* `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> <REF
|
79
|
+
* `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> [<REF>]:
|
80
80
|
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
|
81
81
|
multiple `git push` commands.
|
82
82
|
|
data/test/fakebin/git
CHANGED
data/test/hub_test.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift File.dirname(__FILE__)
|
2
2
|
require 'helper'
|
3
3
|
require 'webmock/test_unit'
|
4
|
+
require 'rbconfig'
|
4
5
|
|
5
6
|
WebMock::BodyPattern.class_eval do
|
6
7
|
undef normalize_hash
|
@@ -17,10 +18,10 @@ class HubTest < Test::Unit::TestCase
|
|
17
18
|
|
18
19
|
COMMANDS = []
|
19
20
|
|
20
|
-
Hub::
|
21
|
-
remove_method :
|
22
|
-
define_method :
|
23
|
-
COMMANDS.include?(name)
|
21
|
+
Hub::Context.class_eval do
|
22
|
+
remove_method :which
|
23
|
+
define_method :which do |name|
|
24
|
+
COMMANDS.include?(name) ? "/usr/bin/#{name}" : nil
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -29,6 +30,8 @@ class HubTest < Test::Unit::TestCase
|
|
29
30
|
Hub::Context::DIRNAME.replace 'hub'
|
30
31
|
Hub::Context::REMOTES.clear
|
31
32
|
|
33
|
+
Hub::Context::GIT_CONFIG.executable = 'git'
|
34
|
+
|
32
35
|
@git = Hub::Context::GIT_CONFIG.replace(Hash.new { |h, k|
|
33
36
|
unless k.index('config alias.') == 0
|
34
37
|
raise ArgumentError, "`git #{k}` not stubbed"
|
@@ -42,8 +45,6 @@ class HubTest < Test::Unit::TestCase
|
|
42
45
|
'config --get-all remote.mislav.url' => 'git://github.com/mislav/hub.git',
|
43
46
|
'config branch.master.remote' => 'origin',
|
44
47
|
'config branch.master.merge' => 'refs/heads/master',
|
45
|
-
'config branch.feature.remote' => 'mislav',
|
46
|
-
'config branch.feature.merge' => 'refs/heads/experimental',
|
47
48
|
'config --bool hub.http-clone' => 'false',
|
48
49
|
'config core.repositoryformatversion' => '0'
|
49
50
|
)
|
@@ -89,7 +90,7 @@ class HubTest < Test::Unit::TestCase
|
|
89
90
|
stub_github_user(nil)
|
90
91
|
end
|
91
92
|
|
92
|
-
assert_equal "** No GitHub user set. See http://github.com/
|
93
|
+
assert_equal "** No GitHub user set. See http://help.github.com/git-email-settings/\n", out
|
93
94
|
end
|
94
95
|
|
95
96
|
def test_your_public_clone_fails_without_config
|
@@ -97,7 +98,7 @@ class HubTest < Test::Unit::TestCase
|
|
97
98
|
stub_github_user(nil)
|
98
99
|
end
|
99
100
|
|
100
|
-
assert_equal "** No GitHub user set. See http://github.com/
|
101
|
+
assert_equal "** No GitHub user set. See http://help.github.com/git-email-settings/\n", out
|
101
102
|
end
|
102
103
|
|
103
104
|
def test_private_clone_left_alone
|
@@ -395,7 +396,11 @@ class HubTest < Test::Unit::TestCase
|
|
395
396
|
stub_github_user(nil)
|
396
397
|
end
|
397
398
|
|
398
|
-
assert_equal "** No GitHub user set. See http://github.com/
|
399
|
+
assert_equal "** No GitHub user set. See http://help.github.com/git-email-settings/\n", out
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_push_untouched
|
403
|
+
assert_forwarded "push"
|
399
404
|
end
|
400
405
|
|
401
406
|
def test_push_two
|
@@ -403,6 +408,12 @@ class HubTest < Test::Unit::TestCase
|
|
403
408
|
"push origin,staging cool-feature"
|
404
409
|
end
|
405
410
|
|
411
|
+
def test_push_current_branch
|
412
|
+
stub_branch('refs/heads/cool-feature')
|
413
|
+
assert_commands "git push origin cool-feature", "git push staging cool-feature",
|
414
|
+
"push origin,staging"
|
415
|
+
end
|
416
|
+
|
406
417
|
def test_push_more
|
407
418
|
assert_commands "git push origin cool-feature",
|
408
419
|
"git push staging cool-feature",
|
@@ -491,7 +502,7 @@ class HubTest < Test::Unit::TestCase
|
|
491
502
|
out = hub("create") do
|
492
503
|
stub_github_token(nil)
|
493
504
|
end
|
494
|
-
assert_equal "** No GitHub token set. See http://github.com/
|
505
|
+
assert_equal "** No GitHub token set. See http://help.github.com/git-email-settings/\n", out
|
495
506
|
end
|
496
507
|
|
497
508
|
def test_create_outside_git_repo
|
@@ -556,7 +567,7 @@ class HubTest < Test::Unit::TestCase
|
|
556
567
|
|
557
568
|
def test_exec_path_arg
|
558
569
|
out = hub('--exec-path=/home/wombat/share/my-l33t-git-core')
|
559
|
-
assert_equal Hub::Commands.improved_help_text,
|
570
|
+
assert_equal Hub::Commands.improved_help_text, out
|
560
571
|
end
|
561
572
|
|
562
573
|
def test_html_path
|
@@ -612,6 +623,7 @@ config
|
|
612
623
|
|
613
624
|
def test_hub_compare_tracking_branch
|
614
625
|
stub_branch('refs/heads/feature')
|
626
|
+
stub_tracking('feature', 'mislav', 'refs/heads/experimental')
|
615
627
|
|
616
628
|
assert_command "compare",
|
617
629
|
"open https://github.com/mislav/hub/compare/experimental"
|
@@ -666,6 +678,7 @@ config
|
|
666
678
|
|
667
679
|
def test_hub_browse_on_branch
|
668
680
|
stub_branch('refs/heads/feature')
|
681
|
+
stub_tracking('feature', 'mislav', 'refs/heads/experimental')
|
669
682
|
|
670
683
|
assert_command "browse resque", "open https://github.com/tpw/resque"
|
671
684
|
assert_command "browse resque commits",
|
@@ -684,6 +697,17 @@ config
|
|
684
697
|
assert_command "browse --", "open https://github.com/defunkt/hub"
|
685
698
|
end
|
686
699
|
|
700
|
+
def test_hub_browse_no_tracking
|
701
|
+
stub_tracking_nothing
|
702
|
+
assert_command "browse", "open https://github.com/defunkt/hub"
|
703
|
+
end
|
704
|
+
|
705
|
+
def test_hub_browse_no_tracking_on_branch
|
706
|
+
stub_branch('refs/heads/feature')
|
707
|
+
stub_tracking('feature', nil, nil)
|
708
|
+
assert_command "browse", "open https://github.com/defunkt/hub"
|
709
|
+
end
|
710
|
+
|
687
711
|
def test_hub_browse_current_wiki
|
688
712
|
stub_repo_url 'git://github.com/defunkt/hub.wiki.git'
|
689
713
|
|
@@ -720,7 +744,7 @@ config
|
|
720
744
|
def test_linux_browser
|
721
745
|
stub_available_commands "open", "xdg-open", "cygstart"
|
722
746
|
with_browser_env(nil) do
|
723
|
-
|
747
|
+
with_host_os("i686-linux") do
|
724
748
|
assert_browser("xdg-open")
|
725
749
|
end
|
726
750
|
end
|
@@ -729,7 +753,7 @@ config
|
|
729
753
|
def test_cygwin_browser
|
730
754
|
stub_available_commands "open", "cygstart"
|
731
755
|
with_browser_env(nil) do
|
732
|
-
|
756
|
+
with_host_os("i686-linux") do
|
733
757
|
assert_browser("cygstart")
|
734
758
|
end
|
735
759
|
end
|
@@ -739,7 +763,7 @@ config
|
|
739
763
|
stub_available_commands()
|
740
764
|
expected = "Please set $BROWSER to a web launcher to use this command.\n"
|
741
765
|
with_browser_env(nil) do
|
742
|
-
|
766
|
+
with_host_os("i686-linux") do
|
743
767
|
assert_equal expected, hub("browse")
|
744
768
|
end
|
745
769
|
end
|
@@ -759,6 +783,12 @@ config
|
|
759
783
|
assert_command "browse", "open https://github.com/my/repo"
|
760
784
|
end
|
761
785
|
|
786
|
+
def test_global_flags_preserved
|
787
|
+
cmd = '--no-pager --bare -c core.awesome=true -c name=value --git-dir=/srv/www perform'
|
788
|
+
assert_command cmd, 'git --bare -c core.awesome=true -c name=value --git-dir=/srv/www --no-pager perform'
|
789
|
+
assert_equal %w[git --bare -c core.awesome=true -c name=value --git-dir=/srv/www], @git.executable
|
790
|
+
end
|
791
|
+
|
762
792
|
protected
|
763
793
|
|
764
794
|
def stub_github_user(name)
|
@@ -778,9 +808,13 @@ config
|
|
778
808
|
@git['symbolic-ref -q HEAD'] = value
|
779
809
|
end
|
780
810
|
|
811
|
+
def stub_tracking(from, remote_name, remote_branch)
|
812
|
+
@git["config branch.#{from}.remote"] = remote_name
|
813
|
+
@git["config branch.#{from}.merge"] = remote_branch
|
814
|
+
end
|
815
|
+
|
781
816
|
def stub_tracking_nothing
|
782
|
-
|
783
|
-
@git['config branch.master.merge'] = nil
|
817
|
+
stub_tracking('master', nil, nil)
|
784
818
|
end
|
785
819
|
|
786
820
|
def stub_remotes_group(name, value)
|
@@ -834,14 +868,14 @@ config
|
|
834
868
|
assert_command "browse", "#{browser} https://github.com/defunkt/hub"
|
835
869
|
end
|
836
870
|
|
837
|
-
def
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
871
|
+
def with_host_os(value)
|
872
|
+
host_os = RbConfig::CONFIG['host_os']
|
873
|
+
RbConfig::CONFIG['host_os'] = value
|
874
|
+
begin
|
875
|
+
yield
|
876
|
+
ensure
|
877
|
+
RbConfig::CONFIG['host_os'] = host_os
|
878
|
+
end
|
845
879
|
end
|
846
880
|
|
847
881
|
end
|
metadata
CHANGED
@@ -1,33 +1,27 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hub
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 6
|
9
|
-
- 0
|
10
|
-
version: 1.6.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Chris Wanstrath
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-03-24 00:00:00 -07:00
|
19
|
-
default_executable:
|
12
|
+
date: 2011-05-13 00:00:00.000000000Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
|
-
|
14
|
+
description: ! " `hub` is a command line utility which adds GitHub knowledge to `git`.\n\n
|
15
|
+
\ It can used on its own or as a `git` wrapper.\n\n Normal:\n\n $ hub clone
|
16
|
+
rtomayko/tilt\n\n Expands to:\n $ git clone git://github.com/rtomayko/tilt.git\n\n
|
17
|
+
\ Wrapping `git`:\n\n $ git clone rack/rack\n\n Expands to:\n $ git
|
18
|
+
clone git://github.com/rack/rack.git\n"
|
23
19
|
email: chris@ozmm.org
|
24
|
-
executables:
|
20
|
+
executables:
|
25
21
|
- hub
|
26
22
|
extensions: []
|
27
|
-
|
28
23
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
24
|
+
files:
|
31
25
|
- README.md
|
32
26
|
- Rakefile
|
33
27
|
- LICENSE
|
@@ -49,58 +43,33 @@ files:
|
|
49
43
|
- test/helper.rb
|
50
44
|
- test/hub_test.rb
|
51
45
|
- test/standalone_test.rb
|
52
|
-
has_rdoc: true
|
53
46
|
homepage: http://github.com/defunkt/hub
|
54
47
|
licenses: []
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
=======================
|
62
|
-
|
63
|
-
If you are a heavy user of `git` on the command
|
64
|
-
line you may want to install `hub` the old
|
65
|
-
fashioned way. Faster startup time, you see.
|
66
|
-
|
67
|
-
Check out the installation instructions at
|
68
|
-
http://github.com/defunkt/hub#readme under the
|
69
|
-
"Standalone" section.
|
70
|
-
|
71
|
-
Cheers,
|
72
|
-
defunkt
|
73
|
-
|
74
|
-
------------------------------------------------------------
|
75
|
-
|
48
|
+
post_install_message: ! "\n------------------------------------------------------------\n\n
|
49
|
+
\ You there! Wait, I say!\n =======================\n\n
|
50
|
+
\ If you are a heavy user of `git` on the command\n line you may want
|
51
|
+
\ to install `hub` the old\n fashioned way. Faster startup time, you
|
52
|
+
see.\n\n Check out the installation instructions at\n http://github.com/defunkt/hub#readme
|
53
|
+
\ under the\n \"Standalone\" section.\n\n Cheers,\n defunkt\n\n------------------------------------------------------------\n\n"
|
76
54
|
rdoc_options: []
|
77
|
-
|
78
|
-
require_paths:
|
55
|
+
require_paths:
|
79
56
|
- lib
|
80
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
58
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
87
|
-
- 0
|
88
|
-
version: "0"
|
89
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
64
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
version: "0"
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
98
69
|
requirements: []
|
99
|
-
|
100
70
|
rubyforge_project:
|
101
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.8.1
|
102
72
|
signing_key:
|
103
73
|
specification_version: 3
|
104
74
|
summary: hub introduces git to GitHub
|
105
75
|
test_files: []
|
106
|
-
|