hub 1.10.3 → 1.10.4
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/HISTORY.md +6 -0
- data/README.md +9 -0
- data/lib/hub/args.rb +0 -1
- data/lib/hub/commands.rb +2 -1
- data/lib/hub/context.rb +8 -1
- data/lib/hub/github_api.rb +26 -4
- data/lib/hub/runner.rb +11 -7
- data/lib/hub/version.rb +1 -1
- data/test/helper.rb +2 -1
- metadata +4 -3
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -48,6 +48,15 @@ git version 1.7.6
|
|
48
48
|
hub version 1.8.3
|
49
49
|
~~~
|
50
50
|
|
51
|
+
#### On Windows
|
52
|
+
|
53
|
+
If you have mysysgit, open "Git Bash" and follow the steps above but put the
|
54
|
+
`hub` executable in `/bin` instead of `~/bin`.
|
55
|
+
|
56
|
+
Avoid aliasing hub as `git` due to the fact that mysysgit automatically
|
57
|
+
configures your prompt to include git information, and you want to avoid slowing
|
58
|
+
that down. See [Is your shell prompt slow?](#is-your-shell-prompt-slow)
|
59
|
+
|
51
60
|
### RubyGems
|
52
61
|
|
53
62
|
Though not recommended, hub can also be installed as a RubyGem:
|
data/lib/hub/args.rb
CHANGED
data/lib/hub/commands.rb
CHANGED
@@ -434,7 +434,8 @@ module Hub
|
|
434
434
|
url = url.sub(%r{(/pull/\d+)/\w*$}, '\1') unless gist
|
435
435
|
ext = gist ? '.txt' : '.patch'
|
436
436
|
url += ext unless File.extname(url) == ext
|
437
|
-
patch_file = File.join(
|
437
|
+
patch_file = File.join(tmp_dir, "#{gist ? 'gist-' : ''}#{File.basename(url)}")
|
438
|
+
# TODO: remove dependency on curl
|
438
439
|
args.before 'curl', ['-#LA', "hub #{Hub::Version}", url, '-o', patch_file]
|
439
440
|
args[idx] = patch_file
|
440
441
|
end
|
data/lib/hub/context.rb
CHANGED
@@ -433,7 +433,10 @@ module Hub
|
|
433
433
|
editor = git_command 'var GIT_EDITOR'
|
434
434
|
editor = ENV[$1] if editor =~ /^\$(\w+)$/
|
435
435
|
editor = File.expand_path editor if (editor =~ /^[~.]/ or editor.index('/')) and editor !~ /["']/
|
436
|
-
|
436
|
+
# avoid shellsplitting "C:\Program Files"
|
437
|
+
if File.exist? editor then [editor]
|
438
|
+
else editor.shellsplit
|
439
|
+
end
|
437
440
|
end
|
438
441
|
|
439
442
|
module System
|
@@ -482,6 +485,10 @@ module Hub
|
|
482
485
|
def command?(name)
|
483
486
|
!which(name).nil?
|
484
487
|
end
|
488
|
+
|
489
|
+
def tmp_dir
|
490
|
+
ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
|
491
|
+
end
|
485
492
|
end
|
486
493
|
|
487
494
|
include System
|
data/lib/hub/github_api.rb
CHANGED
@@ -66,7 +66,7 @@ module Hub
|
|
66
66
|
|
67
67
|
# Public: Create a new project.
|
68
68
|
def create_repo project, options = {}
|
69
|
-
is_org = project.owner != config.username(api_host(project.host))
|
69
|
+
is_org = project.owner.downcase != config.username(api_host(project.host)).downcase
|
70
70
|
params = { :name => project.name, :private => !!options[:private] }
|
71
71
|
params[:description] = options[:description] if options[:description]
|
72
72
|
params[:homepage] = options[:homepage] if options[:homepage]
|
@@ -115,6 +115,7 @@ module Hub
|
|
115
115
|
# Requires access to a `config` object that implements:
|
116
116
|
# - proxy_uri(with_ssl)
|
117
117
|
# - username(host)
|
118
|
+
# - update_username(host, old_username, new_username)
|
118
119
|
# - password(host, user)
|
119
120
|
module HttpMethods
|
120
121
|
# Decorator for Net::HTTPResponse
|
@@ -129,7 +130,12 @@ module Hub
|
|
129
130
|
data['errors'].map do |err|
|
130
131
|
case err['code']
|
131
132
|
when 'custom' then err['message']
|
132
|
-
when 'missing_field'
|
133
|
+
when 'missing_field'
|
134
|
+
%(Missing field: "%s") % err['field']
|
135
|
+
when 'invalid'
|
136
|
+
%(Invalid value for "%s": "%s") % [ err['field'], err['value'] ]
|
137
|
+
when 'unauthorized'
|
138
|
+
%(Not allowed to change field "%s") % err['field']
|
133
139
|
end
|
134
140
|
end.compact if data['errors']
|
135
141
|
end
|
@@ -234,10 +240,18 @@ module Hub
|
|
234
240
|
if (req.path =~ /\/authorizations$/)
|
235
241
|
super
|
236
242
|
else
|
243
|
+
refresh = false
|
237
244
|
user = url.user || config.username(url.host)
|
238
245
|
token = config.oauth_token(url.host, user) {
|
246
|
+
refresh = true
|
239
247
|
obtain_oauth_token url.host, user
|
240
248
|
}
|
249
|
+
if refresh
|
250
|
+
# get current user info user to persist correctly capitalized login name
|
251
|
+
res = get "https://#{url.host}/user"
|
252
|
+
res.error! unless res.success?
|
253
|
+
config.update_username(url.host, user, res.data['login'])
|
254
|
+
end
|
241
255
|
req['Authorization'] = "token #{token}"
|
242
256
|
end
|
243
257
|
end
|
@@ -339,6 +353,12 @@ module Hub
|
|
339
353
|
end
|
340
354
|
end
|
341
355
|
|
356
|
+
def update_username host, old_username, new_username
|
357
|
+
entry = @data.entry_for_user(normalize_host(host), old_username)
|
358
|
+
entry['user'] = new_username
|
359
|
+
@data.save
|
360
|
+
end
|
361
|
+
|
342
362
|
def api_token host, user
|
343
363
|
host = normalize_host host
|
344
364
|
@data.fetch_value host, user, :api_token do
|
@@ -376,9 +396,11 @@ module Hub
|
|
376
396
|
end
|
377
397
|
end
|
378
398
|
|
379
|
-
|
399
|
+
NULL = defined?(File::NULL) ? File::NULL :
|
400
|
+
File.exist?('/dev/null') ? '/dev/null' : 'NUL'
|
401
|
+
|
380
402
|
def askpass
|
381
|
-
tty_state = `stty -g`
|
403
|
+
tty_state = `stty -g 2>#{NULL}`
|
382
404
|
system 'stty raw -echo -icanon isig' if $?.success?
|
383
405
|
pass = ''
|
384
406
|
while char = $stdin.getbyte and !(char == 13 or char == 10)
|
data/lib/hub/runner.rb
CHANGED
@@ -48,17 +48,12 @@ module Hub
|
|
48
48
|
if args.noop?
|
49
49
|
puts commands
|
50
50
|
elsif not args.skip?
|
51
|
-
|
52
|
-
execute_command_chain
|
53
|
-
else
|
54
|
-
exec(*args.to_exec)
|
55
|
-
end
|
51
|
+
execute_command_chain args.commands
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
55
|
# Runs multiple commands in succession; exits at first failure.
|
60
|
-
def execute_command_chain
|
61
|
-
commands = args.commands
|
56
|
+
def execute_command_chain commands
|
62
57
|
commands.each_with_index do |cmd, i|
|
63
58
|
if cmd.respond_to?(:call) then cmd.call
|
64
59
|
elsif i == commands.length - 1
|
@@ -69,5 +64,14 @@ module Hub
|
|
69
64
|
end
|
70
65
|
end
|
71
66
|
end
|
67
|
+
|
68
|
+
# Special-case `echo` for Windows
|
69
|
+
def exec *args
|
70
|
+
if args.first == 'echo' && Context::windows?
|
71
|
+
puts args[1..-1].join(' ')
|
72
|
+
else
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
72
76
|
end
|
73
77
|
end
|
data/lib/hub/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -9,7 +9,8 @@ fakebin_dir = File.expand_path('../fakebin', __FILE__)
|
|
9
9
|
ENV['PATH'] = "#{fakebin_dir}:#{ENV['PATH']}"
|
10
10
|
|
11
11
|
# Use an isolated config file in testing
|
12
|
-
ENV['
|
12
|
+
tmp_dir = ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
|
13
|
+
ENV['HUB_CONFIG'] = File.join(tmp_dir, 'hub-test-config')
|
13
14
|
|
14
15
|
# Disable `abort` and `exit` in the main test process, but allow it in
|
15
16
|
# subprocesses where we need to test does a command properly bail out.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -80,7 +80,8 @@ files:
|
|
80
80
|
- test/hub_test.rb
|
81
81
|
- test/standalone_test.rb
|
82
82
|
homepage: http://defunkt.io/hub/
|
83
|
-
licenses:
|
83
|
+
licenses:
|
84
|
+
- MIT
|
84
85
|
post_install_message: ! "\n------------------------------------------------------------\n\n
|
85
86
|
\ You there! Wait, I say!\n =======================\n\n
|
86
87
|
\ If you are a heavy user of `git` on the command\n line you may want
|