hub 1.10.1 → 1.10.2

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 CHANGED
@@ -1,5 +1,19 @@
1
- ## master
1
+ ## 1.10.2 (2012-07-24)
2
2
 
3
+ * fix pushing multiple refs to multiple remotes
4
+ * support ssh.github.com
5
+ * security: mode for ~/.config/hub is 0600
6
+ * fix integration with GitHub Enterprise API
7
+ * fix cloning repos that start with a period
8
+
9
+ ## 1.10.1 (2012-05-28)
10
+
11
+ * don't choke on empty config file
12
+ * fix `browse` when not in git repo
13
+
14
+ ## 1.10.0 (2012-05-08)
15
+
16
+ * improve improved help text
3
17
  * fix GitHub username prompt in `create` command
4
18
  * make `fetch` command work with private repos too
5
19
  * add `merge` command to merge pull requests
data/README.md CHANGED
@@ -75,7 +75,8 @@ You can also install from source:
75
75
 
76
76
  ~~~ sh
77
77
  $ git clone git://github.com/defunkt/hub.git
78
- $ cd hub && rake install prefix=/usr/local
78
+ $ cd hub
79
+ $ rake install prefix=/usr/local
79
80
  ~~~
80
81
 
81
82
  ### Help! It's Slow!
@@ -333,11 +334,13 @@ $ git clone defunkt/repl
333
334
  Contributing
334
335
  ------------
335
336
 
336
- These instructions assume that you already have hub installed and aliased as
337
+ These instructions assume that _you already have hub installed_ and aliased as
337
338
  `git` (see "Aliasing").
338
339
 
339
340
  1. Clone hub:
340
341
  `git clone defunkt/hub && cd hub`
342
+ 1. Ensure Bundler is installed:
343
+ `which bundle || gem install bundler`
341
344
  1. Install development dependencies:
342
345
  `bundle install`
343
346
  2. Verify that existing tests pass:
data/Rakefile CHANGED
@@ -115,6 +115,12 @@ task :install => "hub" do
115
115
  FileUtils.cp "man/hub.1", "#{prefix}/share/man/man1"
116
116
  end
117
117
 
118
+ #
119
+ # Release
120
+ #
121
+
122
+ task :release => [:pages, :gem_release, :homebrew]
123
+
118
124
  desc "Copy files to gh-pages branch, but don't publish"
119
125
  task :gh_pages => [:check_dirty, "hub", "man/hub.1.html"] do
120
126
  cp "man/hub.1.html", "html"
@@ -133,3 +139,33 @@ task :pages => :gh_pages do
133
139
  sh "git checkout master"
134
140
  puts "Done."
135
141
  end
142
+
143
+ task :gem_release do
144
+ sh "gem release -t"
145
+ end
146
+
147
+ desc "Publish to Homebrew"
148
+ task :homebrew do
149
+ require File.expand_path('../lib/hub/version', __FILE__)
150
+ Dir.chdir `brew --prefix`.chomp do
151
+ sh 'git checkout -q master'
152
+ sh 'git pull -q origin master'
153
+
154
+ formula_file = 'Library/Formula/hub.rb'
155
+ md5 = `curl -#L https://github.com/defunkt/hub/tarball/v#{Hub::VERSION} | md5`.chomp
156
+ abort unless $?.success? and md5.length == 32
157
+
158
+ formula = File.read formula_file
159
+ formula.sub! /\bv\d+(\.\d+)*/, "v#{Hub::VERSION}"
160
+ formula.sub! /\b[0-9a-f]{32}\b/, md5
161
+ File.open(formula_file, 'w') {|f| f << formula }
162
+
163
+ branch = "hub-v#{Hub::VERSION}"
164
+ sh "git checkout -q -B #{branch}"
165
+ sh "git commit -m 'upgrade hub to v#{Hub::VERSION}' -- #{formula_file}"
166
+ sh "git push -u mislav #{branch}"
167
+ sh "hub pull-request 'upgrade hub to v#{Hub::VERSION}'"
168
+
169
+ sh "git checkout -q master"
170
+ end
171
+ end
@@ -34,7 +34,7 @@ module Hub
34
34
  # provides git interrogation methods
35
35
  extend Context
36
36
 
37
- NAME_RE = /\w[\w.-]*/
37
+ NAME_RE = /[\w.][\w.-]*/
38
38
  OWNER_RE = /[a-zA-Z0-9-]+/
39
39
  NAME_WITH_OWNER_RE = /^(?:#{NAME_RE}|#{OWNER_RE}\/#{NAME_RE})$/
40
40
 
@@ -544,12 +544,18 @@ module Hub
544
544
  def push(args)
545
545
  return if args[1].nil? || !args[1].index(',')
546
546
 
547
- branch = (args[2] ||= current_branch.short_name)
547
+ refs = args.words[2..-1]
548
548
  remotes = args[1].split(',')
549
549
  args[1] = remotes.shift
550
550
 
551
+ if refs.empty?
552
+ # add current branch as explicit ref when there are no refs specified
553
+ refs = [current_branch.short_name]
554
+ args.concat refs
555
+ end
556
+
551
557
  remotes.each do |name|
552
- args.after ['push', name, branch]
558
+ args.after ['push', name, *refs]
553
559
  end
554
560
  end
555
561
 
@@ -989,7 +995,7 @@ help
989
995
  end
990
996
 
991
997
  def display_api_exception(action, response)
992
- $stderr.puts "Error #{action}: #{response.message} (HTTP #{response.status})"
998
+ $stderr.puts "Error #{action}: #{response.message.strip} (HTTP #{response.status})"
993
999
  if 422 == response.status and response.error_message?
994
1000
  # display validation errors
995
1001
  msg = response.error_message
@@ -185,7 +185,11 @@ module Hub
185
185
  end
186
186
 
187
187
  def known_hosts
188
- git_config('hub.host', :all).to_s.split("\n") + [default_host]
188
+ hosts = git_config('hub.host', :all).to_s.split("\n")
189
+ hosts << default_host
190
+ # support ssh.github.com
191
+ # https://help.github.com/articles/using-ssh-over-the-https-port
192
+ hosts << "ssh.#{default_host}"
189
193
  end
190
194
 
191
195
  def self.default_host
@@ -217,6 +221,7 @@ module Hub
217
221
  def initialize(*args)
218
222
  super
219
223
  self.host ||= (local_repo || LocalRepo).default_host
224
+ self.host = host.sub(/^ssh\./i, '') if 'ssh.github.com' == host.downcase
220
225
  end
221
226
 
222
227
  def private?
@@ -154,7 +154,7 @@ module Hub
154
154
  url = URI.parse url unless url.respond_to? :host
155
155
 
156
156
  require 'net/https'
157
- req = Net::HTTP.const_get(type).new(url.request_uri)
157
+ req = Net::HTTP.const_get(type).new request_uri(url)
158
158
  # TODO: better naming?
159
159
  http = configure_connection(req, url) do |host_url|
160
160
  create_connection host_url
@@ -169,6 +169,12 @@ module Hub
169
169
  raise Context::FatalError, "error with #{type.to_s.upcase} #{url} (#{err.message})"
170
170
  end
171
171
 
172
+ def request_uri url
173
+ str = url.request_uri
174
+ str = '/api/v3' << str if url.host != 'api.github.com'
175
+ str
176
+ end
177
+
172
178
  def configure_connection req, url
173
179
  if ENV['HUB_TEST_HOST']
174
180
  req['Host'] = url.host
@@ -211,7 +217,7 @@ module Hub
211
217
 
212
218
  module OAuth
213
219
  def apply_authentication req, url
214
- if req.path.index('/authorizations') == 0
220
+ if (req.path =~ /\/authorizations$/)
215
221
  super
216
222
  else
217
223
  user = url.user || config.username(url.host)
@@ -286,12 +292,12 @@ module Hub
286
292
 
287
293
  def load
288
294
  existing_data = File.read(@filename)
289
- @data.update YAML.load existing_data unless existing_data.strip.empty?
295
+ @data.update YAML.load(existing_data) unless existing_data.strip.empty?
290
296
  end
291
297
 
292
298
  def save
293
299
  FileUtils.mkdir_p File.dirname(@filename)
294
- File.open(@filename, 'w') {|f| f << YAML.dump(@data) }
300
+ File.open(@filename, 'w', 0600) {|f| f << YAML.dump(@data) }
295
301
  end
296
302
  end
297
303
 
@@ -359,7 +365,7 @@ module Hub
359
365
  tty_state = `stty -g`
360
366
  system 'stty raw -echo -icanon isig' if $?.success?
361
367
  pass = ''
362
- while char = $stdin.getbyte and not (char == 13 or char == 10)
368
+ while char = $stdin.getbyte and !(char == 13 or char == 10)
363
369
  if char == 127 or char == 8
364
370
  pass[-1,1] = '' unless pass.empty?
365
371
  else
@@ -1,3 +1,3 @@
1
1
  module Hub
2
- Version = VERSION = '1.10.1'
2
+ Version = VERSION = '1.10.2'
3
3
  end
@@ -4,6 +4,7 @@ require 'rbconfig'
4
4
  require 'yaml'
5
5
  require 'forwardable'
6
6
  require 'fileutils'
7
+ require 'tempfile'
7
8
 
8
9
  WebMock::BodyPattern.class_eval do
9
10
  undef normalize_hash
@@ -244,6 +245,12 @@ class HubTest < Test::Unit::TestCase
244
245
  "push origin,staging,qa cool-feature"
245
246
  end
246
247
 
248
+ def test_push_multiple_refs
249
+ assert_commands "git push origin master new-feature",
250
+ "git push staging master new-feature",
251
+ "push origin,staging master new-feature"
252
+ end
253
+
247
254
  def test_pullrequest
248
255
  expected = "Aborted: head branch is the same as base (\"master\")\n" <<
249
256
  "(use `-h <branch>` to specify an explicit pull request head)\n"
@@ -315,11 +322,11 @@ class HubTest < Test::Unit::TestCase
315
322
  data['git.my.org'] = [{'user'=>'myfiname', 'oauth_token' => 'FITOKEN'}]
316
323
  end
317
324
 
318
- stub_request(:post, "https://git.my.org/repos/defunkt/hub/pulls").
325
+ stub_request(:post, "https://git.my.org/api/v3/repos/defunkt/hub/pulls").
319
326
  with(:body => {'base' => "master", 'head' => "myfiname:feature", 'title' => "hereyougo" }).
320
- to_return(:body => mock_pullreq_response(1, 'defunkt/hub', 'git.my.org'))
327
+ to_return(:body => mock_pullreq_response(1, 'api/v3/defunkt/hub', 'git.my.org'))
321
328
 
322
- expected = "https://git.my.org/defunkt/hub/pull/1\n"
329
+ expected = "https://git.my.org/api/v3/defunkt/hub/pull/1\n"
323
330
  assert_output expected, "pull-request hereyougo -f"
324
331
  end
325
332
 
@@ -578,12 +585,19 @@ class HubTest < Test::Unit::TestCase
578
585
  end
579
586
 
580
587
  def test_hub_browse_ssh_alias
581
- with_ssh_config do
588
+ with_ssh_config "Host gh\n User git\n HostName github.com" do
582
589
  stub_repo_url "gh:singingwolfboy/sekrit.git"
583
590
  assert_command "browse", "open https://github.com/singingwolfboy/sekrit"
584
591
  end
585
592
  end
586
593
 
594
+ def test_hub_browse_ssh_github_alias
595
+ with_ssh_config "Host github.com\n HostName ssh.github.com" do
596
+ stub_repo_url "git@github.com:suan/git-sanity.git"
597
+ assert_command "browse", "open https://github.com/suan/git-sanity"
598
+ end
599
+ end
600
+
587
601
  def test_custom_browser
588
602
  with_browser_env("custom") do
589
603
  assert_browser("custom")
@@ -748,10 +762,17 @@ class HubTest < Test::Unit::TestCase
748
762
  Hub::Commands.send :improved_help_text
749
763
  end
750
764
 
751
- def with_ssh_config
752
- config_file = File.expand_path '../ssh_config', __FILE__
753
- Hub::SshConfig::CONFIG_FILES.replace [config_file]
754
- yield
765
+ def with_ssh_config content
766
+ config_file = Tempfile.open 'ssh_config'
767
+ config_file << content
768
+ config_file.close
769
+
770
+ begin
771
+ Hub::SshConfig::CONFIG_FILES.replace [config_file.path]
772
+ yield
773
+ ensure
774
+ config_file.unlink
775
+ end
755
776
  end
756
777
 
757
778
  end
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.1
4
+ version: 1.10.2
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-05-28 00:00:00.000000000 Z
13
+ date: 2012-07-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -78,7 +78,6 @@ files:
78
78
  - test/fakebin/open
79
79
  - test/helper.rb
80
80
  - test/hub_test.rb
81
- - test/ssh_config
82
81
  - test/standalone_test.rb
83
82
  homepage: http://defunkt.io/hub/
84
83
  licenses: []
@@ -1,3 +0,0 @@
1
- Host gh
2
- User git
3
- HostName github.com