hub 1.12.0 → 1.12.2
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.
- checksums.yaml +7 -0
- data/README.md +1 -1
- data/Rakefile +3 -2
- data/bin/hub +2 -0
- data/lib/hub/commands.rb +46 -37
- data/lib/hub/context.rb +6 -4
- data/lib/hub/github_api.rb +23 -2
- data/lib/hub/standalone.rb +2 -1
- data/lib/hub/version.rb +1 -1
- metadata +48 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31c0677c16aef1654f0bb45debbd4bb13711b80c
|
4
|
+
data.tar.gz: b05264bdc353d8ba0875402951cf5fcb869fe0bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5b0533962cce93062ca8e65b29d4c916008b7394d3cddcc700cec8b379e26e7f11fb0ab398cdadea7a6d905d81966f9637ecaa416320b2fdabea8db5e482a31
|
7
|
+
data.tar.gz: 87fce8fb1670724bcdb9c169df01998be68fbd260341529a2f8677d669575256e6f5df2a1af900e90f52b67a7172641e8554ece4d296a8111552757895eb9ab7
|
data/README.md
CHANGED
@@ -235,7 +235,7 @@ superpowers:
|
|
235
235
|
### git checkout
|
236
236
|
|
237
237
|
$ git checkout https://github.com/defunkt/hub/pull/73
|
238
|
-
> git remote add -f -t feature git://github
|
238
|
+
> git remote add -f -t feature mislav git://github.com/mislav/hub.git
|
239
239
|
> git checkout --track -B mislav-feature mislav/feature
|
240
240
|
|
241
241
|
$ git checkout https://github.com/defunkt/hub/pull/73 custom-branch-name
|
data/Rakefile
CHANGED
@@ -157,6 +157,7 @@ end
|
|
157
157
|
desc "Publish to Homebrew"
|
158
158
|
task :homebrew do
|
159
159
|
require File.expand_path('../lib/hub/version', __FILE__)
|
160
|
+
ENV['RUBYOPT'] = ''
|
160
161
|
Dir.chdir `brew --prefix`.chomp do
|
161
162
|
sh 'git checkout -q master'
|
162
163
|
sh 'git pull -q origin master'
|
@@ -172,9 +173,9 @@ task :homebrew do
|
|
172
173
|
|
173
174
|
branch = "hub-v#{Hub::VERSION}"
|
174
175
|
sh "git checkout -q -B #{branch}"
|
175
|
-
sh "git commit -m 'hub
|
176
|
+
sh "git commit -m 'hub #{Hub::VERSION}' -- #{formula_file}"
|
176
177
|
sh "git push -u mislav #{branch}"
|
177
|
-
sh "hub pull-request -m '
|
178
|
+
sh "hub pull-request -m 'hub #{Hub::VERSION}'"
|
178
179
|
|
179
180
|
sh "git checkout -q master"
|
180
181
|
end
|
data/bin/hub
CHANGED
data/lib/hub/commands.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
module Hub
|
2
4
|
# The Commands module houses the git commands that hub
|
3
5
|
# lovingly wraps. If a method exists here, it is expected to have a
|
@@ -220,7 +222,7 @@ module Hub
|
|
220
222
|
when 0
|
221
223
|
default_message = commit_summary = nil
|
222
224
|
when 1
|
223
|
-
format = '%
|
225
|
+
format = '%s%n%+b'
|
224
226
|
default_message = git_command "show -s --format='#{format}' #{commits.first}"
|
225
227
|
commit_summary = nil
|
226
228
|
else
|
@@ -230,14 +232,14 @@ module Hub
|
|
230
232
|
[format, base_branch, remote_branch]
|
231
233
|
end
|
232
234
|
|
233
|
-
options[:title], options[:body] = pullrequest_editmsg(commit_summary) { |msg, initial_message|
|
235
|
+
options[:title], options[:body] = pullrequest_editmsg(commit_summary) { |msg, initial_message, cc|
|
234
236
|
initial_message ||= default_message
|
235
237
|
msg.puts initial_message if initial_message
|
236
238
|
msg.puts ""
|
237
|
-
msg.puts "# Requesting a pull to #{base_project.owner}:#{options[:base]} from #{options[:head]}"
|
238
|
-
msg.puts "#"
|
239
|
-
msg.puts "# Write a message for this pull request. The first block"
|
240
|
-
msg.puts "# of text is the title and the rest is description."
|
239
|
+
msg.puts "#{cc} Requesting a pull to #{base_project.owner}:#{options[:base]} from #{options[:head]}"
|
240
|
+
msg.puts "#{cc}"
|
241
|
+
msg.puts "#{cc} Write a message for this pull request. The first block"
|
242
|
+
msg.puts "#{cc} of text is the title and the rest is description."
|
241
243
|
}
|
242
244
|
end
|
243
245
|
|
@@ -443,8 +445,9 @@ module Hub
|
|
443
445
|
user, branch = pull_data['head']['label'].split(':', 2)
|
444
446
|
abort "Error: #{user}'s fork is not available anymore" unless pull_data['head']['repo']
|
445
447
|
|
446
|
-
|
447
|
-
|
448
|
+
repo_name = pull_data['head']['repo']['name']
|
449
|
+
url = github_project(repo_name, user).git_url(:private => pull_data['head']['repo']['private'],
|
450
|
+
:https => https_protocol?)
|
448
451
|
|
449
452
|
merge_head = "#{user}/#{branch}"
|
450
453
|
args.before ['fetch', url, "+refs/heads/#{branch}:refs/remotes/#{merge_head}"]
|
@@ -495,15 +498,19 @@ module Hub
|
|
495
498
|
# ... downloads patch via API ...
|
496
499
|
# > git am /tmp/55.patch
|
497
500
|
def am(args)
|
498
|
-
|
499
|
-
|
500
|
-
if
|
501
|
-
|
502
|
-
|
501
|
+
gh_url = nil
|
502
|
+
idx = args.index { |arg|
|
503
|
+
gh_url = if arg =~ %r{^https?://gist\.github\.com/} then URI(arg)
|
504
|
+
else resolve_github_url(arg)
|
505
|
+
end
|
506
|
+
}
|
507
|
+
|
508
|
+
if gh_url
|
509
|
+
if "gist.github.com" == gh_url.host
|
510
|
+
gist_id = gh_url.path.split('/').last
|
503
511
|
patch_name = "gist-#{gist_id}.txt"
|
504
512
|
patch = api_client.gist_raw(gist_id)
|
505
513
|
else
|
506
|
-
gh_url = resolve_github_url(url)
|
507
514
|
case gh_url.project_path
|
508
515
|
when /^pull\/(\d+)/
|
509
516
|
pull_id = $1.to_i
|
@@ -518,7 +525,7 @@ module Hub
|
|
518
525
|
end
|
519
526
|
end
|
520
527
|
|
521
|
-
patch_file =
|
528
|
+
patch_file = Tempfile.new(patch_name).path
|
522
529
|
File.open(patch_file, 'w') { |file| file.write(patch) }
|
523
530
|
args[idx] = patch_file
|
524
531
|
end
|
@@ -685,7 +692,7 @@ module Hub
|
|
685
692
|
project = local_repo.main_project
|
686
693
|
else
|
687
694
|
# $ hub browse
|
688
|
-
prefer_upstream = current_branch.master?
|
695
|
+
prefer_upstream = current_branch && current_branch.master?
|
689
696
|
branch, project = remote_branch_and_project(method(:github_user), prefer_upstream)
|
690
697
|
branch ||= master_branch
|
691
698
|
end
|
@@ -732,7 +739,7 @@ module Hub
|
|
732
739
|
end
|
733
740
|
end
|
734
741
|
|
735
|
-
path = '/compare/%s' % range
|
742
|
+
path = '/compare/%s' % range
|
736
743
|
project.web_url(path, api_client.config.method(:protocol))
|
737
744
|
end
|
738
745
|
end
|
@@ -807,7 +814,7 @@ module Hub
|
|
807
814
|
command = args.words[1]
|
808
815
|
|
809
816
|
if command == 'hub' || custom_command?(command)
|
810
|
-
|
817
|
+
paginated_puts hub_manpage
|
811
818
|
exit
|
812
819
|
elsif command.nil?
|
813
820
|
if args.has_flag?('-a', '--all')
|
@@ -815,8 +822,11 @@ module Hub
|
|
815
822
|
args.after 'echo', ["\nhub custom commands\n"]
|
816
823
|
args.after 'echo', CUSTOM_COMMANDS.map {|cmd| " #{cmd}" }
|
817
824
|
else
|
818
|
-
|
819
|
-
|
825
|
+
if args.has_flag?('-p', '--paginate')
|
826
|
+
paginated_puts improved_help_text
|
827
|
+
else
|
828
|
+
puts improved_help_text
|
829
|
+
end
|
820
830
|
exit
|
821
831
|
end
|
822
832
|
end
|
@@ -861,14 +871,13 @@ module Hub
|
|
861
871
|
pattern = /(git|hub) #{Regexp.escape args[0].gsub('-', '\-')}/
|
862
872
|
hub_raw_manpage.each_line { |line|
|
863
873
|
if line =~ pattern
|
864
|
-
|
865
|
-
$stderr.puts line.gsub(/\\f./, '').gsub('\-', '-')
|
874
|
+
puts "Usage: " + line.gsub(/\\f./, '').gsub('\-', '-')
|
866
875
|
abort
|
867
876
|
end
|
868
877
|
}
|
869
878
|
abort "Error: couldn't find usage help for #{args[0]}"
|
870
879
|
when '--help'
|
871
|
-
|
880
|
+
paginated_puts hub_manpage
|
872
881
|
exit
|
873
882
|
end
|
874
883
|
end
|
@@ -1004,7 +1013,7 @@ help
|
|
1004
1013
|
# in order to turn our raw roff (manpage markup) into something
|
1005
1014
|
# readable on the terminal.
|
1006
1015
|
def groff_command
|
1007
|
-
cols = terminal_width
|
1016
|
+
cols = [terminal_width - 1, 120].min
|
1008
1017
|
"groff -Wall -mtty-char -mandoc -Tascii -rLL=#{cols}n -rLT=#{cols}n"
|
1009
1018
|
end
|
1010
1019
|
|
@@ -1023,11 +1032,9 @@ help
|
|
1023
1032
|
end
|
1024
1033
|
end
|
1025
1034
|
|
1026
|
-
|
1027
|
-
# git-style.
|
1028
|
-
def puts(*args)
|
1035
|
+
def paginated_puts(*args)
|
1029
1036
|
page_stdout
|
1030
|
-
|
1037
|
+
puts(*args)
|
1031
1038
|
end
|
1032
1039
|
|
1033
1040
|
# http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
|
@@ -1042,8 +1049,9 @@ help
|
|
1042
1049
|
read.close
|
1043
1050
|
write.close
|
1044
1051
|
|
1045
|
-
#
|
1046
|
-
|
1052
|
+
# S: chop long lines
|
1053
|
+
# R: support ANSI color escape sequences
|
1054
|
+
ENV['LESS'] = 'SR'
|
1047
1055
|
|
1048
1056
|
# Wait until we have input before we start the pager
|
1049
1057
|
Kernel.select [STDIN]
|
@@ -1069,17 +1077,18 @@ help
|
|
1069
1077
|
|
1070
1078
|
def pullrequest_editmsg(changes)
|
1071
1079
|
message_file = pullrequest_editmsg_file
|
1080
|
+
cc = git_commentchar
|
1072
1081
|
|
1073
1082
|
if valid_editmsg_file?(message_file)
|
1074
|
-
title, body = read_editmsg(message_file)
|
1083
|
+
title, body = read_editmsg(message_file, cc)
|
1075
1084
|
previous_message = [title, body].compact.join("\n\n") if title
|
1076
1085
|
end
|
1077
1086
|
|
1078
1087
|
File.open(message_file, 'w') { |msg|
|
1079
|
-
yield msg, previous_message
|
1088
|
+
yield msg, previous_message, cc
|
1080
1089
|
if changes
|
1081
|
-
msg.puts "
|
1082
|
-
msg.puts changes.gsub(/^/,
|
1090
|
+
msg.puts "#{cc}\n#{cc} Changes:\n#{cc}"
|
1091
|
+
msg.puts changes.gsub(/^/, "#{cc} ").gsub(/ +$/, '')
|
1083
1092
|
end
|
1084
1093
|
}
|
1085
1094
|
|
@@ -1094,7 +1103,7 @@ help
|
|
1094
1103
|
abort "error using text editor for pull request message"
|
1095
1104
|
end
|
1096
1105
|
|
1097
|
-
title, body = read_editmsg(message_file)
|
1106
|
+
title, body = read_editmsg(message_file, cc)
|
1098
1107
|
abort "Aborting due to empty pull request title" unless title
|
1099
1108
|
[title, body]
|
1100
1109
|
end
|
@@ -1115,11 +1124,11 @@ help
|
|
1115
1124
|
File.join(git_dir, 'PULLREQ_EDITMSG')
|
1116
1125
|
end
|
1117
1126
|
|
1118
|
-
def read_editmsg(file)
|
1127
|
+
def read_editmsg(file, commentchar)
|
1119
1128
|
title, body = '', ''
|
1120
1129
|
File.open(file, 'r') { |msg|
|
1121
1130
|
msg.each_line do |line|
|
1122
|
-
next if line.index(
|
1131
|
+
next if line.index(commentchar) == 0
|
1123
1132
|
((title.empty? and line =~ /\S/) ? title : body) << line
|
1124
1133
|
end
|
1125
1134
|
}
|
data/lib/hub/context.rb
CHANGED
@@ -504,6 +504,12 @@ module Hub
|
|
504
504
|
end
|
505
505
|
end
|
506
506
|
|
507
|
+
def git_commentchar
|
508
|
+
if str = git_config('core.commentchar') then str[0,1]
|
509
|
+
else '#'
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
507
513
|
module System
|
508
514
|
# Cross-platform web browser command; respects the value set in $BROWSER.
|
509
515
|
#
|
@@ -556,10 +562,6 @@ module Hub
|
|
556
562
|
!which(name).nil?
|
557
563
|
end
|
558
564
|
|
559
|
-
def tmp_dir
|
560
|
-
ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
|
561
|
-
end
|
562
|
-
|
563
565
|
def terminal_width
|
564
566
|
if unix?
|
565
567
|
width = %x{stty size 2>#{NULL}}.split[1].to_i
|
data/lib/hub/github_api.rb
CHANGED
@@ -192,12 +192,33 @@ module Hub
|
|
192
192
|
end
|
193
193
|
end.compact if data['errors']
|
194
194
|
end
|
195
|
+
def links
|
196
|
+
@links ||= self['link'].to_s.scan(/<(.+?)>; rel="(.+?)"/).inject({}) do |map, (url, rel)|
|
197
|
+
map.update(rel.to_sym => URI.parse(url))
|
198
|
+
end
|
199
|
+
end
|
200
|
+
def next_url() links[:next] end
|
195
201
|
end
|
196
202
|
|
197
203
|
def get url, &block
|
198
204
|
perform_request url, :Get, &block
|
199
205
|
end
|
200
206
|
|
207
|
+
def get_all url, &block
|
208
|
+
previous_res = nil
|
209
|
+
user = url.user
|
210
|
+
while url
|
211
|
+
res = get(url, &block)
|
212
|
+
if url = res.next_url
|
213
|
+
url = url.dup
|
214
|
+
url.user = user
|
215
|
+
end
|
216
|
+
res.data.unshift(*previous_res.data) if res.success? && previous_res
|
217
|
+
previous_res = res
|
218
|
+
end
|
219
|
+
res
|
220
|
+
end
|
221
|
+
|
201
222
|
def post url, params = nil
|
202
223
|
perform_request url, :Post do |req|
|
203
224
|
if params
|
@@ -299,7 +320,7 @@ module Hub
|
|
299
320
|
|
300
321
|
module OAuth
|
301
322
|
def apply_authentication req, url
|
302
|
-
if req.path =~ %r{^(/api/v3)?/authorizations
|
323
|
+
if req.path =~ %r{^(/api/v3)?/authorizations\b}
|
303
324
|
super
|
304
325
|
else
|
305
326
|
user = url.user ? CGI.unescape(url.user) : config.username(url.host)
|
@@ -317,7 +338,7 @@ module Hub
|
|
317
338
|
post(auth_url) if !two_factor_code
|
318
339
|
|
319
340
|
# first try to fetch existing authorization
|
320
|
-
res =
|
341
|
+
res = get_all(auth_url) do |req|
|
321
342
|
req['X-GitHub-OTP'] = two_factor_code if two_factor_code
|
322
343
|
end
|
323
344
|
unless res.success?
|
data/lib/hub/standalone.rb
CHANGED
@@ -25,6 +25,7 @@ preamble
|
|
25
25
|
def build io
|
26
26
|
io.puts "#!#{ruby_shebang}"
|
27
27
|
io << PREAMBLE
|
28
|
+
io.puts "Encoding.default_external = 'UTF-8' if defined?(Encoding)"
|
28
29
|
|
29
30
|
each_source_file do |filename|
|
30
31
|
File.open(filename, 'r') do |source|
|
@@ -76,7 +77,7 @@ preamble
|
|
76
77
|
|
77
78
|
def ruby_shebang
|
78
79
|
ruby = ruby_executable
|
79
|
-
|
80
|
+
`RUBYOPT= #{ruby_executable} --disable-gems -e0 2>/dev/null`
|
80
81
|
if $?.success?
|
81
82
|
"#{ruby} --disable-gems"
|
82
83
|
else
|
data/lib/hub/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
5
|
-
prerelease:
|
4
|
+
version: 1.12.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Wanstrath
|
@@ -10,22 +9,37 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2014-
|
12
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
|
-
description:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
description: |2
|
15
|
+
`hub` is a command line utility which adds GitHub knowledge to `git`.
|
16
|
+
|
17
|
+
It can used on its own or as a `git` wrapper.
|
18
|
+
|
19
|
+
Normal:
|
20
|
+
|
21
|
+
$ hub clone rtomayko/tilt
|
22
|
+
|
23
|
+
Expands to:
|
24
|
+
$ git clone git://github.com/rtomayko/tilt.git
|
25
|
+
|
26
|
+
Wrapping `git`:
|
27
|
+
|
28
|
+
$ git clone rack/rack
|
29
|
+
|
30
|
+
Expands to:
|
31
|
+
$ git clone git://github.com/rack/rack.git
|
20
32
|
email: mislav.marohnic@gmail.com
|
21
33
|
executables:
|
22
34
|
- hub
|
23
35
|
extensions: []
|
24
36
|
extra_rdoc_files: []
|
25
37
|
files:
|
38
|
+
- LICENSE
|
26
39
|
- README.md
|
27
40
|
- Rakefile
|
28
|
-
-
|
41
|
+
- bin/hub
|
42
|
+
- lib/hub.rb
|
29
43
|
- lib/hub/args.rb
|
30
44
|
- lib/hub/commands.rb
|
31
45
|
- lib/hub/context.rb
|
@@ -36,39 +50,50 @@ files:
|
|
36
50
|
- lib/hub/ssh_config.rb
|
37
51
|
- lib/hub/standalone.rb
|
38
52
|
- lib/hub/version.rb
|
39
|
-
- lib/hub.rb
|
40
|
-
- bin/hub
|
41
53
|
- man/hub.1
|
42
54
|
- man/hub.1.html
|
43
55
|
- man/hub.1.ronn
|
44
56
|
homepage: http://hub.github.com/
|
45
57
|
licenses:
|
46
58
|
- MIT
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
59
|
+
metadata: {}
|
60
|
+
post_install_message: |2+
|
61
|
+
|
62
|
+
------------------------------------------------------------
|
63
|
+
|
64
|
+
You there! Wait, I say!
|
65
|
+
=======================
|
66
|
+
|
67
|
+
If you are a heavy user of `git` on the command
|
68
|
+
line you may want to install `hub` the old
|
69
|
+
fashioned way. Faster startup time, you see.
|
70
|
+
|
71
|
+
Check out the installation instructions at
|
72
|
+
https://github.com/github/hub#readme under the
|
73
|
+
"Standalone" section.
|
74
|
+
|
75
|
+
Cheers,
|
76
|
+
defunkt
|
77
|
+
|
78
|
+
------------------------------------------------------------
|
79
|
+
|
53
80
|
rdoc_options: []
|
54
81
|
require_paths:
|
55
82
|
- lib
|
56
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
84
|
requirements:
|
59
|
-
- -
|
85
|
+
- - ">="
|
60
86
|
- !ruby/object:Gem::Version
|
61
87
|
version: '0'
|
62
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
89
|
requirements:
|
65
|
-
- -
|
90
|
+
- - ">="
|
66
91
|
- !ruby/object:Gem::Version
|
67
92
|
version: '0'
|
68
93
|
requirements: []
|
69
94
|
rubyforge_project:
|
70
|
-
rubygems_version:
|
95
|
+
rubygems_version: 2.2.0
|
71
96
|
signing_key:
|
72
|
-
specification_version:
|
97
|
+
specification_version: 4
|
73
98
|
summary: Command-line wrapper for git and GitHub
|
74
99
|
test_files: []
|