hub 1.11.2 → 1.12.0

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.

@@ -111,6 +111,10 @@ module Hub
111
111
  $stdout.puts ref_state
112
112
  end
113
113
  exit exit_code
114
+ rescue GitHubAPI::Exceptions
115
+ response = $!.response
116
+ display_api_exception("fetching CI status", response)
117
+ exit 1
114
118
  end
115
119
 
116
120
  # $ hub pull-request
@@ -158,11 +162,13 @@ module Hub
158
162
  head_project, options[:head] = from_github_ref.call(head, head_project)
159
163
  when '-i'
160
164
  options[:issue] = args.shift
165
+ when '-o', '--browse'
166
+ open_with_browser = true
161
167
  else
162
168
  if url = resolve_github_url(arg) and url.project_path =~ /^issues\/(\d+)/
163
169
  options[:issue] = $1
164
170
  base_project = url.project
165
- elsif !options[:title]
171
+ elsif !options[:title] && arg.index('-') != 0
166
172
  options[:title] = arg
167
173
  warn "hub: Specifying pull request title without a flag is deprecated."
168
174
  warn "Please use one of `-m' or `-F' options."
@@ -237,8 +243,10 @@ module Hub
237
243
 
238
244
  pull = api_client.create_pullrequest(options)
239
245
 
240
- args.executable = 'echo'
241
- args.replace [pull['html_url']]
246
+ args.push('-u') unless open_with_browser
247
+ browse_command(args) do
248
+ pull['html_url']
249
+ end
242
250
  rescue GitHubAPI::Exceptions
243
251
  response = $!.response
244
252
  display_api_exception("creating pull request", response)
@@ -693,7 +701,7 @@ module Hub
693
701
  "/#{subpage}"
694
702
  end
695
703
 
696
- project.web_url(path)
704
+ project.web_url(path, api_client.config.method(:protocol))
697
705
  end
698
706
  end
699
707
 
@@ -724,7 +732,8 @@ module Hub
724
732
  end
725
733
  end
726
734
 
727
- project.web_url "/compare/#{range.tr('/', ';')}"
735
+ path = '/compare/%s' % range.tr('/', ';')
736
+ project.web_url(path, api_client.config.method(:protocol))
728
737
  end
729
738
  end
730
739
 
@@ -829,7 +838,9 @@ module Hub
829
838
  config_file = ENV['HUB_CONFIG'] || '~/.config/hub'
830
839
  file_store = GitHubAPI::FileStore.new File.expand_path(config_file)
831
840
  file_config = GitHubAPI::Configuration.new file_store
832
- GitHubAPI.new file_config, :app_url => 'http://hub.github.com/'
841
+ GitHubAPI.new file_config,
842
+ :app_url => 'http://hub.github.com/',
843
+ :verbose => !ENV['HUB_VERBOSE'].to_s.empty?
833
844
  end
834
845
  end
835
846
 
@@ -1032,7 +1043,7 @@ help
1032
1043
  write.close
1033
1044
 
1034
1045
  # Don't page if the input is short enough
1035
- ENV['LESS'] = 'FSRX'
1046
+ ENV['LESS'] = 'FSR'
1036
1047
 
1037
1048
  # Wait until we have input before we start the pager
1038
1049
  Kernel.select [STDIN]
@@ -288,7 +288,7 @@ module Hub
288
288
  local_repo.remotes.find { |r| r.project == self }
289
289
  end
290
290
 
291
- def web_url(path = nil)
291
+ def web_url(path = nil, protocol_config = nil)
292
292
  project_name = name_with_owner
293
293
  if project_name.sub!(/\.wiki$/, '')
294
294
  unless '/wiki' == path
@@ -298,7 +298,11 @@ module Hub
298
298
  path = '/wiki' + path
299
299
  end
300
300
  end
301
- "https://#{host}/" + project_name + path.to_s
301
+ '%s://%s/%s' % [
302
+ protocol_config ? protocol_config.call(host) : 'https',
303
+ host,
304
+ project_name + path.to_s
305
+ ]
302
306
  end
303
307
 
304
308
  def git_url(options = {})
@@ -27,8 +27,11 @@ module Hub
27
27
  def initialize config, options
28
28
  @config = config
29
29
  @oauth_app_url = options.fetch(:app_url)
30
+ @verbose = options.fetch(:verbose, false)
30
31
  end
31
32
 
33
+ def verbose?() @verbose end
34
+
32
35
  # Fake exception type for net/http exception handling.
33
36
  # Necessary because net/http may or may not be loaded at the time.
34
37
  module Exceptions
@@ -180,6 +183,8 @@ module Hub
180
183
  when 'custom' then err['message']
181
184
  when 'missing_field'
182
185
  %(Missing field: "%s") % err['field']
186
+ when 'already_exists'
187
+ %(Duplicate value for "%s") % err['field']
183
188
  when 'invalid'
184
189
  %(Invalid value for "%s": "%s") % [ err['field'], err['value'] ]
185
190
  when 'unauthorized'
@@ -246,8 +251,10 @@ module Hub
246
251
  end
247
252
 
248
253
  def configure_connection req, url
254
+ url.scheme = config.protocol(url.host)
249
255
  if ENV['HUB_TEST_HOST']
250
256
  req['Host'] = url.host
257
+ req['X-Original-Scheme'] = url.scheme
251
258
  url = url.dup
252
259
  url.scheme = 'http'
253
260
  url.host, test_port = ENV['HUB_TEST_HOST'].split(':')
@@ -322,7 +329,7 @@ module Hub
322
329
  end
323
330
  end
324
331
 
325
- if found = res.data.find {|auth| auth['app']['url'] == oauth_app_url }
332
+ if found = res.data.find {|auth| auth['note'] == 'hub' || auth['note_url'] == oauth_app_url }
326
333
  found['token']
327
334
  else
328
335
  # create a new authorization
@@ -342,9 +349,63 @@ module Hub
342
349
  end
343
350
  end
344
351
 
352
+ module Verbose
353
+ def finalize_request(req, url)
354
+ super
355
+ dump_request_info(req, url) if verbose?
356
+ end
357
+
358
+ def perform_request(*)
359
+ res = super
360
+ dump_response_info(res) if verbose?
361
+ res
362
+ end
363
+
364
+ def verbose_puts(msg)
365
+ msg = "\e[36m%s\e[m" % msg if $stderr.tty?
366
+ $stderr.puts msg
367
+ end
368
+
369
+ def dump_request_info(req, url)
370
+ verbose_puts "> %s %s://%s%s" % [
371
+ req.method.to_s.upcase,
372
+ url.scheme,
373
+ url.host,
374
+ req.path,
375
+ ]
376
+ dump_headers(req, '> ')
377
+ dump_body(req)
378
+ end
379
+
380
+ def dump_response_info(res)
381
+ verbose_puts "< HTTP %s" % res.status
382
+ dump_headers(res, '< ')
383
+ dump_body(res)
384
+ end
385
+
386
+ def dump_body(obj)
387
+ verbose_puts obj.body if obj.body
388
+ end
389
+
390
+ DUMP_HEADERS = %w[ Authorization X-GitHub-OTP Location ]
391
+
392
+ def dump_headers(obj, indent)
393
+ DUMP_HEADERS.each do |header|
394
+ if value = obj[header]
395
+ verbose_puts '%s%s: %s' % [
396
+ indent,
397
+ header,
398
+ value.sub(/^(basic|token) (.+)/i, '\1 [REDACTED]'),
399
+ ]
400
+ end
401
+ end
402
+ end
403
+ end
404
+
345
405
  include HttpMethods
346
406
  include OAuth
347
407
  include GistAuth
408
+ include Verbose
348
409
 
349
410
  # Filesystem store suitable for Configuration
350
411
  class FileStore
@@ -472,6 +533,11 @@ module Hub
472
533
  end
473
534
  end
474
535
 
536
+ def protocol host
537
+ host = normalize_host host
538
+ @data.fetch_value(host, nil, :protocol) { 'https' }
539
+ end
540
+
475
541
  def value_to_persist(value = nil)
476
542
  @data.persist_next_change!
477
543
  value
@@ -481,6 +547,7 @@ module Hub
481
547
  print "#{what}: "
482
548
  $stdin.gets.chomp
483
549
  rescue Interrupt
550
+ puts
484
551
  abort
485
552
  end
486
553
 
@@ -496,6 +563,7 @@ module Hub
496
563
  $stdin.gets.chomp
497
564
  end
498
565
  rescue Interrupt
566
+ puts
499
567
  abort
500
568
  end
501
569
 
@@ -503,6 +571,7 @@ module Hub
503
571
  print "two-factor authentication code: "
504
572
  $stdin.gets.chomp
505
573
  rescue Interrupt
574
+ puts
506
575
  abort
507
576
  end
508
577
 
@@ -1,3 +1,3 @@
1
1
  module Hub
2
- Version = VERSION = '1.11.2'
2
+ Version = VERSION = '1.12.0'
3
3
  end
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" "December 2013" "GITHUB" "Hub Manual"
4
+ .TH "HUB" "1" "February 2014" "GITHUB" "Hub Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBhub\fR \- git + hub = github
@@ -61,7 +61,7 @@
61
61
  \fBgit fork\fR [\fB\-\-no\-remote\fR]
62
62
  .
63
63
  .br
64
- \fBgit pull\-request\fR [\fB\-f\fR] [\fB\-m\fR \fIMESSAGE\fR|\fB\-F\fR \fIFILE\fR|\fB\-i\fR \fIISSUE\fR|\fIISSUE\-URL\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
64
+ \fBgit pull\-request\fR [\fB\-o\fR|\fB\-\-browse\fR] [\fB\-f\fR] [\fB\-m\fR \fIMESSAGE\fR|\fB\-F\fR \fIFILE\fR|\fB\-i\fR \fIISSUE\fR|\fIISSUE\-URL\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
65
65
  .
66
66
  .br
67
67
  \fBgit ci\-status\fR [\fB\-v\fR] [\fICOMMIT\fR]
@@ -148,13 +148,16 @@ Open a GitHub compare view page in the system\'s default web browser\. \fISTART\
148
148
  Forks the original project (referenced by "origin" remote) on GitHub and adds a new remote for it under your username\.
149
149
  .
150
150
  .TP
151
- \fBgit pull\-request\fR [\fB\-f\fR] [\fB\-m\fR \fIMESSAGE\fR|\fB\-F\fR \fIFILE\fR|\fB\-i\fR \fIISSUE\fR|\fIISSUE\-URL\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
151
+ \fBgit pull\-request\fR [\fB\-o\fR|\fB\-\-browse\fR] [\fB\-f\fR] [\fB\-m\fR \fIMESSAGE\fR|\fB\-F\fR \fIFILE\fR|\fB\-i\fR \fIISSUE\fR|\fIISSUE\-URL\fR] [\fB\-b\fR \fIBASE\fR] [\fB\-h\fR \fIHEAD\fR]
152
152
  Opens a pull request on GitHub for the project that the "origin" remote points to\. The default head of the pull request is the current branch\. Both base and head of the pull request can be explicitly given in one of the following formats: "branch", "owner:branch", "owner/repo:branch"\. This command will abort operation if it detects that the current topic branch has local commits that are not yet pushed to its upstream branch on the remote\. To skip this check, use \fB\-f\fR\.
153
153
  .
154
154
  .IP
155
155
  Without \fIMESSAGE\fR or \fIFILE\fR, a text editor will open in which title and body of the pull request can be entered in the same manner as git commit message\. Pull request message can also be passed via stdin with \fB\-F \-\fR\.
156
156
  .
157
157
  .IP
158
+ With \fB\-o\fR or \fB\-\-browse\fR, the new pull request will open in the web browser\.
159
+ .
160
+ .IP
158
161
  Issue to pull request conversion via \fB\-i <ISSUE>\fR or \fIISSUE\-URL\fR arguments is deprecated and will likely be removed from the future versions of both hub and GitHub API\.
159
162
  .
160
163
  .TP
@@ -100,7 +100,7 @@
100
100
  <code>git browse</code> [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>] [SUBPAGE]<br />
101
101
  <code>git compare</code> [<code>-u</code>] [<var>USER</var>] [[<var>START</var>...]<var>END</var>]<br />
102
102
  <code>git fork</code> [<code>--no-remote</code>]<br />
103
- <code>git pull-request</code> [<code>-f</code>] [<code>-m</code> <var>MESSAGE</var>|<code>-F</code> <var>FILE</var>|<code>-i</code> <var>ISSUE</var>|<var>ISSUE-URL</var>] [<code>-b</code> <var>BASE</var>] [<code>-h</code> <var>HEAD</var>]<br />
103
+ <code>git pull-request</code> [<code>-o</code>|<code>--browse</code>] [<code>-f</code>] [<code>-m</code> <var>MESSAGE</var>|<code>-F</code> <var>FILE</var>|<code>-i</code> <var>ISSUE</var>|<var>ISSUE-URL</var>] [<code>-b</code> <var>BASE</var>] [<code>-h</code> <var>HEAD</var>]<br />
104
104
  <code>git ci-status</code> [<code>-v</code>] [<var>COMMIT</var>]</p>
105
105
 
106
106
  <h2 id="DESCRIPTION">DESCRIPTION</h2>
@@ -184,7 +184,7 @@ If <var>END</var> is omitted, GitHub compare view is opened for the current bran
184
184
  With <code>-u</code>, outputs the URL rather than opening the browser.</p></dd>
185
185
  <dt><code>git fork</code> [<code>--no-remote</code>]</dt><dd><p>Forks the original project (referenced by "origin" remote) on GitHub and
186
186
  adds a new remote for it under your username.</p></dd>
187
- <dt><code>git pull-request</code> [<code>-f</code>] [<code>-m</code> <var>MESSAGE</var>|<code>-F</code> <var>FILE</var>|<code>-i</code> <var>ISSUE</var>|<var>ISSUE-URL</var>] [<code>-b</code> <var>BASE</var>] [<code>-h</code> <var>HEAD</var>]</dt><dd><p>Opens a pull request on GitHub for the project that the "origin" remote
187
+ <dt><code>git pull-request</code> [<code>-o</code>|<code>--browse</code>] [<code>-f</code>] [<code>-m</code> <var>MESSAGE</var>|<code>-F</code> <var>FILE</var>|<code>-i</code> <var>ISSUE</var>|<var>ISSUE-URL</var>] [<code>-b</code> <var>BASE</var>] [<code>-h</code> <var>HEAD</var>]</dt><dd><p>Opens a pull request on GitHub for the project that the "origin" remote
188
188
  points to. The default head of the pull request is the current branch.
189
189
  Both base and head of the pull request can be explicitly given in one of
190
190
  the following formats: "branch", "owner:branch", "owner/repo:branch".
@@ -196,6 +196,8 @@ on the remote. To skip this check, use <code>-f</code>.</p>
196
196
  of the pull request can be entered in the same manner as git commit message.
197
197
  Pull request message can also be passed via stdin with <code>-F -</code>.</p>
198
198
 
199
+ <p>With <code>-o</code> or <code>--browse</code>, the new pull request will open in the web browser.</p>
200
+
199
201
  <p>Issue to pull request conversion via <code>-i &lt;ISSUE></code> or <var>ISSUE-URL</var>
200
202
  arguments is deprecated and will likely be removed from the future versions
201
203
  of both hub and GitHub API.</p></dd>
@@ -457,7 +459,7 @@ $ git help hub
457
459
 
458
460
  <ol class='man-decor man-foot man foot'>
459
461
  <li class='tl'>GITHUB</li>
460
- <li class='tc'>December 2013</li>
462
+ <li class='tc'>February 2014</li>
461
463
  <li class='tr'>hub(1)</li>
462
464
  </ol>
463
465
 
@@ -27,7 +27,7 @@ hub(1) -- git + hub = github
27
27
  `git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]
28
28
  `git compare` [`-u`] [<USER>] [[<START>...]<END>]
29
29
  `git fork` [`--no-remote`]
30
- `git pull-request` [`-f`] [`-m` <MESSAGE>|`-F` <FILE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]
30
+ `git pull-request` [`-o`|`--browse`] [`-f`] [`-m` <MESSAGE>|`-F` <FILE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]
31
31
  `git ci-status` [`-v`] [<COMMIT>]
32
32
 
33
33
  ## DESCRIPTION
@@ -142,7 +142,7 @@ hub also adds some custom commands that are otherwise not present in git:
142
142
  Forks the original project (referenced by "origin" remote) on GitHub and
143
143
  adds a new remote for it under your username.
144
144
 
145
- * `git pull-request` [`-f`] [`-m` <MESSAGE>|`-F` <FILE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]:
145
+ * `git pull-request` [`-o`|`--browse`] [`-f`] [`-m` <MESSAGE>|`-F` <FILE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]:
146
146
  Opens a pull request on GitHub for the project that the "origin" remote
147
147
  points to. The default head of the pull request is the current branch.
148
148
  Both base and head of the pull request can be explicitly given in one of
@@ -155,6 +155,8 @@ hub also adds some custom commands that are otherwise not present in git:
155
155
  of the pull request can be entered in the same manner as git commit message.
156
156
  Pull request message can also be passed via stdin with `-F -`.
157
157
 
158
+ With `-o` or `--browse`, the new pull request will open in the web browser.
159
+
158
160
  Issue to pull request conversion via `-i <ISSUE>` or <ISSUE-URL>
159
161
  arguments is deprecated and will likely be removed from the future versions
160
162
  of both hub and GitHub API.
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.2
4
+ version: 1.12.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Chris Wanstrath
@@ -9,37 +10,22 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-02-02 00:00:00.000000000 Z
13
+ date: 2014-03-01 00:00:00.000000000 Z
13
14
  dependencies: []
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
15
+ description: ! " `hub` is a command line utility which adds GitHub knowledge to `git`.\n\n
16
+ \ It can used on its own or as a `git` wrapper.\n\n Normal:\n\n $ hub clone
17
+ rtomayko/tilt\n\n Expands to:\n $ git clone git://github.com/rtomayko/tilt.git\n\n
18
+ \ Wrapping `git`:\n\n $ git clone rack/rack\n\n Expands to:\n $ git
19
+ clone git://github.com/rack/rack.git\n"
32
20
  email: mislav.marohnic@gmail.com
33
21
  executables:
34
22
  - hub
35
23
  extensions: []
36
24
  extra_rdoc_files: []
37
25
  files:
38
- - LICENSE
39
26
  - README.md
40
27
  - Rakefile
41
- - bin/hub
42
- - lib/hub.rb
28
+ - LICENSE
43
29
  - lib/hub/args.rb
44
30
  - lib/hub/commands.rb
45
31
  - lib/hub/context.rb
@@ -50,50 +36,39 @@ files:
50
36
  - lib/hub/ssh_config.rb
51
37
  - lib/hub/standalone.rb
52
38
  - lib/hub/version.rb
39
+ - lib/hub.rb
40
+ - bin/hub
53
41
  - man/hub.1
54
42
  - man/hub.1.html
55
43
  - man/hub.1.ronn
56
44
  homepage: http://hub.github.com/
57
45
  licenses:
58
46
  - MIT
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
-
47
+ post_install_message: ! "\n------------------------------------------------------------\n\n
48
+ \ You there! Wait, I say!\n =======================\n\n
49
+ \ If you are a heavy user of `git` on the command\n line you may want
50
+ \ to install `hub` the old\n fashioned way. Faster startup time, you
51
+ see.\n\n Check out the installation instructions at\n https://github.com/github/hub#readme
52
+ \ under the\n \"Standalone\" section.\n\n Cheers,\n defunkt\n\n------------------------------------------------------------\n\n"
80
53
  rdoc_options: []
81
54
  require_paths:
82
55
  - lib
83
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
84
58
  requirements:
85
- - - ">="
59
+ - - ! '>='
86
60
  - !ruby/object:Gem::Version
87
61
  version: '0'
88
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
89
64
  requirements:
90
- - - ">="
65
+ - - ! '>='
91
66
  - !ruby/object:Gem::Version
92
67
  version: '0'
93
68
  requirements: []
94
69
  rubyforge_project:
95
- rubygems_version: 2.2.0
70
+ rubygems_version: 1.8.23
96
71
  signing_key:
97
- specification_version: 4
72
+ specification_version: 3
98
73
  summary: Command-line wrapper for git and GitHub
99
74
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 33425262679ba4de3ce4878fc66c286f6d25ef3b
4
- data.tar.gz: 521fb0f37a0ee0d416952ced4d411b6b59812283
5
- SHA512:
6
- metadata.gz: 57892fa9c30df8535ad45f3add227a01ceb5914b6886b77562ec7a3fd4e876885f0fb4e2087659673017c7cfa0fec2675c23fd873c7152f2991b243474b5bfb1
7
- data.tar.gz: 372b734e8ad6ea150dde927387fda9d3d3b0957574e50800c2806d5b1f58c2385734efd97d5170c280ecf231325d596c9f1de0206b32a0da0ef012d09a51251a