hub 1.12.3 → 1.12.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5407dc0fb9ed147f8062d7fc71105e47917d81f5
4
- data.tar.gz: 822b2cea8f672f01c39a020d8ae7e0f32948c057
3
+ metadata.gz: fb7e38c89dc87f9e05027c6f4d0bd062783352ab
4
+ data.tar.gz: f7642761346978a2a7d1fce314c1c3116cc32311
5
5
  SHA512:
6
- metadata.gz: 8685da13cb734dc61dc20ad80fc54967bbfd3f00b8b72b4e99f600d16f25e89e87abd20db7783b9a04ac37cc61e948bc313ca7a94ce083e55c9b761d481d0392
7
- data.tar.gz: f5bb42ef98e1282d6aacb9e5ee1d0a6f69c9cb2ee702848f25a122dd090d1e0023b0a995333bb1eb98dd0fe426c0cf74b17517c0c9ce05e9d905637574ff19a2
6
+ metadata.gz: 109f3785e3159fa9b6f1ab597d7f8ef001c0be3b66434c95cd8e833342e7e22007965ce7fdc79edda44a491b1eb07a8b09c2edaada22e971a39b5c8407ddf963
7
+ data.tar.gz: 79bec54832b2b6fa32e8b363d5911e795df7b1c54b9de7eb373fc5534fbcf57be0e07b66def7bb37be30598e0d72c237be94d158585c700a79a468fa06b832c9
data/README.md CHANGED
@@ -38,19 +38,17 @@ supports hub is available:
38
38
 
39
39
  ~~~ sh
40
40
  # Download or clone the project from GitHub:
41
- $ git clone git://github.com/github/hub.git
41
+ $ git clone git://github.com/github/hub.git -b 1.12-stable
42
42
  $ cd hub
43
- $ rake install
43
+ $ rake install PREFIX=/usr/local
44
44
  ~~~
45
45
 
46
- On a Unix-based OS, this installs under `PREFIX`, which is `/usr/local` by default.
47
-
48
46
  Now you should be ready to roll:
49
47
 
50
48
  ~~~ sh
51
49
  $ hub version
52
- git version 1.7.6
53
- hub version 1.8.3
50
+ git version 2.1.4
51
+ hub version 1.12.4
54
52
  ~~~
55
53
 
56
54
  #### Windows "Git Bash" (msysGit) note
data/Rakefile CHANGED
@@ -151,7 +151,13 @@ task :pages => :gh_pages do
151
151
  end
152
152
 
153
153
  task :gem_release do
154
- sh "gem release -t"
154
+ require File.expand_path('../lib/hub/version', __FILE__)
155
+ # sh "git add lib/hub/version.rb"
156
+ # sh "git commit -m 'hub #{Hub::VERSION}'"
157
+ # sh "git tag v#{Hub::VERSION}"
158
+ sh "RUBYOPT= git push origin HEAD v#{Hub::VERSION}"
159
+ sh "gem build hub.gemspec"
160
+ sh "gem push hub-#{Hub::VERSION}.gem"
155
161
  end
156
162
 
157
163
  desc "Publish to Homebrew"
@@ -359,6 +359,11 @@ module Hub
359
359
  args.pop
360
360
  end
361
361
 
362
+ if user.downcase == github_user.downcase
363
+ user = github_user
364
+ ssh = true
365
+ end
366
+
362
367
  args << git_url(user, repo, :private => ssh)
363
368
  end
364
369
 
@@ -704,9 +709,9 @@ module Hub
704
709
 
705
710
  path = case subpage
706
711
  when 'commits'
707
- "/commits/#{branch_in_url(branch)}"
712
+ "/commits/#{branch_in_url(branch.short_name)}"
708
713
  when 'tree', NilClass
709
- "/tree/#{branch_in_url(branch)}" if branch and !branch.master?
714
+ "/tree/#{branch_in_url(branch.short_name)}" if branch and !branch.master?
710
715
  else
711
716
  "/#{subpage}"
712
717
  end
@@ -742,7 +747,8 @@ module Hub
742
747
  end
743
748
  end
744
749
 
745
- path = '/compare/%s' % range
750
+ escaped_range = range.include?('..') ? range : branch_in_url(range)
751
+ path = '/compare/%s' % escaped_range
746
752
  project.web_url(path, api_client.config.method(:protocol))
747
753
  end
748
754
  end
@@ -842,8 +848,10 @@ module Hub
842
848
  # from the command line.
843
849
  #
844
850
 
845
- def branch_in_url(branch)
846
- CGI.escape(branch.short_name).gsub("%2F", "/")
851
+ def branch_in_url(branch_name)
852
+ branch_name.to_str.gsub(/[^\w!.*'():^~\/-]/) do |char|
853
+ '%' + char.unpack('H2' * char.bytesize).join('%').upcase
854
+ end
847
855
  end
848
856
 
849
857
  def api_client
@@ -1157,8 +1165,7 @@ help
1157
1165
 
1158
1166
  def display_api_exception(action, response)
1159
1167
  $stderr.puts "Error #{action}: #{response.message.strip} (HTTP #{response.status})"
1160
- if 422 == response.status and response.error_message?
1161
- # display validation errors
1168
+ if [401, 403, 422].include?(response.status) && response.error_message?
1162
1169
  msg = response.error_message
1163
1170
  msg = msg.join("\n") if msg.respond_to? :join
1164
1171
  warn msg
@@ -333,36 +333,49 @@ module Hub
333
333
  end
334
334
  end
335
335
 
336
- def obtain_oauth_token host, user, two_factor_code = nil
336
+ def obtain_oauth_token host, user
337
337
  auth_url = URI.parse("https://%s@%s/authorizations" % [CGI.escape(user), host])
338
+ auth_params = {
339
+ :scopes => ['repo'],
340
+ :note => "hub for #{local_user}@#{local_hostname}",
341
+ :note_url => oauth_app_url
342
+ }
343
+ res = nil
344
+ two_factor_code = nil
338
345
 
339
- # dummy request to trigger a 2FA SMS since a HTTP GET won't do it
340
- post(auth_url) if !two_factor_code
346
+ loop do
347
+ res = post(auth_url, auth_params) do |req|
348
+ req['X-GitHub-OTP'] = two_factor_code if two_factor_code
349
+ end
341
350
 
342
- # first try to fetch existing authorization
343
- res = get_all(auth_url) do |req|
344
- req['X-GitHub-OTP'] = two_factor_code if two_factor_code
345
- end
346
- unless res.success?
347
- if !two_factor_code && res['X-GitHub-OTP'].to_s.include?('required')
351
+ if res.success?
352
+ break
353
+ elsif res.status == 401 && res['X-GitHub-OTP'].to_s.include?('required')
354
+ $stderr.puts "warning: invalid two-factor code" if two_factor_code
348
355
  two_factor_code = config.prompt_auth_code
349
- return obtain_oauth_token(host, user, two_factor_code)
356
+ elsif res.status == 422 && 'already_exists' == res.data['errors'][0]['code']
357
+ if auth_params[:note] =~ / (\d+)$/
358
+ res.error! if $1.to_i >= 9
359
+ auth_params[:note].succ!
360
+ else
361
+ auth_params[:note] += ' 2'
362
+ end
350
363
  else
351
364
  res.error!
352
365
  end
353
366
  end
354
367
 
355
- if found = res.data.find {|auth| auth['note'] == 'hub' || auth['note_url'] == oauth_app_url }
356
- found['token']
357
- else
358
- # create a new authorization
359
- res = post auth_url,
360
- :scopes => %w[repo], :note => 'hub', :note_url => oauth_app_url do |req|
361
- req['X-GitHub-OTP'] = two_factor_code if two_factor_code
362
- end
363
- res.error! unless res.success?
364
- res.data['token']
365
- end
368
+ res.data['token']
369
+ end
370
+
371
+ def local_user
372
+ require 'etc'
373
+ Etc.getlogin
374
+ end
375
+
376
+ def local_hostname
377
+ require 'socket'
378
+ Socket.gethostname
366
379
  end
367
380
  end
368
381
 
@@ -38,7 +38,19 @@ unless defined?(URI)
38
38
  InvalidComponentError = Class.new(Error)
39
39
 
40
40
  def self.parse(str)
41
- URI::HTTP.new(str)
41
+ m = str.to_s.match(%r{^ ([\w-]+): // (?:([^/@]+)@)? ([^/?#]+) }x)
42
+ raise InvalidURIError unless m
43
+
44
+ _, scheme, userinfo, host = m.to_a
45
+ default_port = scheme == 'https' ? 443 : 80
46
+ host, port = host.split(':', 2)
47
+ port = port ? port.to_i : default_port
48
+
49
+ path, fragment = m.post_match.split('#', 2)
50
+ path, query = path.split('?', 2) if path
51
+ path = path.to_s
52
+
53
+ URI::HTTP.new(scheme, userinfo, host, port, nil, path, nil, query, fragment)
42
54
  end
43
55
 
44
56
  def self.encode_www_form(params)
@@ -61,15 +73,14 @@ unless defined?(URI)
61
73
  attr_reader :port
62
74
  alias hostname host
63
75
 
64
- def initialize(str)
65
- m = str.to_s.match(%r{^ ([\w-]+): // (?:([^/@]+)@)? ([^/?#]+) }x)
66
- raise InvalidURIError unless m
67
- _, self.scheme, self.userinfo, host = m.to_a
68
- self.host, port = host.split(':', 2)
69
- self.port = port ? port.to_i : default_port
70
- path, self.fragment = m.post_match.split('#', 2)
71
- path, self.query = path.split('?', 2) if path
72
- self.path = path.to_s
76
+ def initialize(scheme, userinfo, host, port, registry, path, opaque, query, fragment, *extra)
77
+ self.scheme = scheme
78
+ self.userinfo = userinfo
79
+ self.host = host
80
+ self.port = port
81
+ self.path = path
82
+ self.query = query
83
+ self.fragment = fragment
73
84
  end
74
85
 
75
86
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Hub
2
- Version = VERSION = '1.12.3'
2
+ Version = VERSION = '1.12.4'
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" "February 2014" "GITHUB" "Hub Manual"
4
+ .TH "HUB" "1" "December 2014" "GITHUB" "Hub Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBhub\fR \- git + hub = github
@@ -52,7 +52,7 @@
52
52
  \fBgit create\fR [\fINAME\fR] [\fB\-p\fR] [\fB\-d\fR \fIDESCRIPTION\fR] [\fB\-h\fR \fIHOMEPAGE\fR]
53
53
  .
54
54
  .br
55
- \fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
55
+ \fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR|\-\- [SUBPAGE]]
56
56
  .
57
57
  .br
58
58
  \fBgit compare\fR [\fB\-u\fR] [\fIUSER\fR] [[\fISTART\fR\.\.\.]\fIEND\fR]
@@ -136,7 +136,7 @@ hub also adds some custom commands that are otherwise not present in git:
136
136
  Create a new public GitHub repository from the current git repository and add remote \fBorigin\fR at "git@github\.com:\fIUSER\fR/\fIREPOSITORY\fR\.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory name\. To explicitly name the new repository, pass in \fINAME\fR, optionally in \fIORGANIZATION\fR/\fINAME\fR form to create under an organization you\'re a member of\. With \fB\-p\fR, create a private repository, and with \fB\-d\fR and \fB\-h\fR set the repository\'s description and homepage URL, respectively\.
137
137
  .
138
138
  .TP
139
- \fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR] [SUBPAGE]
139
+ \fBgit browse\fR [\fB\-u\fR] [[\fIUSER\fR\fB/\fR]\fIREPOSITORY\fR|\-\- [SUBPAGE]]
140
140
  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")\. With \fB\-u\fR, outputs the URL rather than opening the browser\.
141
141
  .
142
142
  .TP
@@ -327,7 +327,7 @@ $ git pull\-request \-m "Implemented feature X" \-b defunkt:master \-h mislav:fe
327
327
  .nf
328
328
 
329
329
  $ git checkout https://github\.com/defunkt/hub/pull/73
330
- > git remote add \-f \-t feature git://github:com/mislav/hub\.git
330
+ > git remote add \-f \-t feature mislav git://github\.com/mislav/hub\.git
331
331
  > git checkout \-\-track \-B mislav\-feature mislav/feature
332
332
 
333
333
  $ git checkout https://github\.com/defunkt/hub/pull/73 custom\-branch\-name
@@ -97,7 +97,7 @@
97
97
  <h3 id="Custom-git-commands-">Custom git commands:</h3>
98
98
 
99
99
  <p><code>git create</code> [<var>NAME</var>] [<code>-p</code>] [<code>-d</code> <var>DESCRIPTION</var>] [<code>-h</code> <var>HOMEPAGE</var>]<br />
100
- <code>git browse</code> [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>] [SUBPAGE]<br />
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
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 />
@@ -169,7 +169,7 @@ To explicitly name the new repository, pass in <var>NAME</var>, optionally in
169
169
  <var>ORGANIZATION</var>/<var>NAME</var> form to create under an organization you're a
170
170
  member of. With <code>-p</code>, create a private repository, and with <code>-d</code> and <code>-h</code>
171
171
  set the repository's description and homepage URL, respectively.</p></dd>
172
- <dt><code>git browse</code> [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>] [SUBPAGE]</dt><dd><p>Open repository's GitHub page in the system's default web browser using
172
+ <dt><code>git browse</code> [<code>-u</code>] [[<var>USER</var><code>/</code>]<var>REPOSITORY</var>|-- [SUBPAGE]]</dt><dd><p>Open repository's GitHub page in the system's default web browser using
173
173
  <code>open(1)</code> or the <code>BROWSER</code> env variable. If the repository isn't
174
174
  specified, <code>browse</code> opens the page of the repository found in the current
175
175
  directory. If SUBPAGE is specified, the browser will open on the specified
@@ -330,7 +330,7 @@ $ git pull-request -m "Implemented feature X" -b defunkt:master -h mislav:featur
330
330
  <h3 id="git-checkout">git checkout</h3>
331
331
 
332
332
  <pre><code>$ git checkout https://github.com/defunkt/hub/pull/73
333
- &gt; git remote add -f -t feature git://github:com/mislav/hub.git
333
+ &gt; git remote add -f -t feature mislav git://github.com/mislav/hub.git
334
334
  &gt; git checkout --track -B mislav-feature mislav/feature
335
335
 
336
336
  $ git checkout https://github.com/defunkt/hub/pull/73 custom-branch-name
@@ -459,7 +459,7 @@ $ git help hub
459
459
 
460
460
  <ol class='man-decor man-foot man foot'>
461
461
  <li class='tl'>GITHUB</li>
462
- <li class='tc'>February 2014</li>
462
+ <li class='tc'>December 2014</li>
463
463
  <li class='tr'>hub(1)</li>
464
464
  </ol>
465
465
 
@@ -24,7 +24,7 @@ hub(1) -- git + hub = github
24
24
  ### Custom git commands:
25
25
 
26
26
  `git create` [<NAME>] [`-p`] [`-d` <DESCRIPTION>] [`-h` <HOMEPAGE>]
27
- `git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]
27
+ `git browse` [`-u`] [[<USER>`/`]<REPOSITORY>|-- [SUBPAGE]]
28
28
  `git compare` [`-u`] [<USER>] [[<START>...]<END>]
29
29
  `git fork` [`--no-remote`]
30
30
  `git pull-request` [`-o`|`--browse`] [`-f`] [`-m` <MESSAGE>|`-F` <FILE>|`-i` <ISSUE>|<ISSUE-URL>] [`-b` <BASE>] [`-h` <HEAD>]
@@ -121,7 +121,7 @@ hub also adds some custom commands that are otherwise not present in git:
121
121
  member of. With `-p`, create a private repository, and with `-d` and `-h`
122
122
  set the repository's description and homepage URL, respectively.
123
123
 
124
- * `git browse` [`-u`] [[<USER>`/`]<REPOSITORY>] [SUBPAGE]:
124
+ * `git browse` [`-u`] [[<USER>`/`]<REPOSITORY>|-- [SUBPAGE]]:
125
125
  Open repository's GitHub page in the system's default web browser using
126
126
  `open(1)` or the `BROWSER` env variable. If the repository isn't
127
127
  specified, `browse` opens the page of the repository found in the current
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.12.3
4
+ version: 1.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-28 00:00:00.000000000 Z
12
+ date: 2014-12-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |2
15
15
  `hub` is a command line utility which adds GitHub knowledge to `git`.