git_pr 0.0.8 → 0.0.9

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: 7dd812898dce3ddc1a3640e6e2313f0e825c61c2
4
- data.tar.gz: 2f94a7acbf7ee95099dfc834256300d981dd4bb2
3
+ metadata.gz: 011c22bbbb24143c1bab09ee5d53aff9446fd4ac
4
+ data.tar.gz: 3ff6bef6c765bed54291f933d6a47a664b302eac
5
5
  SHA512:
6
- metadata.gz: 06cb3c21ac7e1fd42d1b34756099615641ff2aeddc82060bee1c293dbbc16f2b73e35ea36ae54892bf98898a4a528fd3a58a4d8f09e075fbaf104e3327b93967
7
- data.tar.gz: f9888e80c161f5eba816f81cf3f8425ee41db36d8ec8cff205f9ac95083c3595cfd7d1169a10696fec87c3b40da424153e5bd11eb5fe385258a09fec9a815308
6
+ metadata.gz: f0d4b63380be765e9e2201ff436bdf34c9779fb5eda138902a4f1641ce17bdeccfeaf85f096a4e968b77c8e1cbfb051d58bb14fe0f99eaf14d7c93b33e9277ba
7
+ data.tar.gz: 4fd93b31cc3fe78d3b93b2ac9e7f5f20a279a6610194faaec6f4c47f6e9a8fed04d8a51e24d9288296782bcaf19812bdb3884e3c778001324b9c98f850271206
data/bin/git-pr CHANGED
@@ -234,7 +234,7 @@ when "open"
234
234
  # We didn't find a matching pull request, so let's try to open the "create
235
235
  # pull request" page.
236
236
  source = source
237
- if not git.is_local_branch? source
237
+ if not git.is_local_branch_fast? source
238
238
  puts "Unknown branch '#{source}'.".red
239
239
  exit -1
240
240
  end
@@ -250,8 +250,8 @@ when "open"
250
250
  # https://github.com/FiftyThree/Studio/compare/FiftyThree:master...floatplane:blobstore
251
251
  # So I need to: get the upstream for the named branch. Extract the github project owner.
252
252
  github_target_owner, github_target_project = github_project.split "/"
253
- remote_source_branch = git.branches.remote.find { |b| b.name == source }
254
- remote_url = remote_source_branch ? remote_source_branch.remote.url : nil
253
+ remote = git.find_remote_for_local_branch source
254
+ remote_url = remote ? remote.url : nil
255
255
  unless remote_url and remote_url.match /github\.com/
256
256
  puts "Branch '#{source}' has never been pushed to GitHub."
257
257
  exit -1
data/lib/git_pr/git.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'git'
2
+
3
+ # Add some methods to the git class that operate a lot faster than the defaults
4
+ class Git::Base
5
+
6
+ # Default implementation of is_local_branch? will create O(N) Git::Branch
7
+ # objects for all branches, local *and* remote. All we care about is
8
+ # existence, so we don't need all that.
9
+ def is_local_branch_fast?(branch)
10
+ self.chdir do
11
+ local_branches = `git branch`.split.map { |b| b.gsub('*', '').strip }
12
+ local_branches.include? branch
13
+ end
14
+ end
15
+
16
+ # Shortcut to create a remote for a particular branch, if the branch has an upstream.
17
+ def find_remote_for_local_branch(branch)
18
+ self.chdir do
19
+ remote_name = `git for-each-ref --format='%(upstream:short)' refs/heads/#{branch}`.strip.sub(/\/#{branch}$/, '')
20
+ remote_name.empty? ? nil : Git::Remote.new(self, remote_name)
21
+ end
22
+ end
23
+
24
+ end
data/lib/git_pr/github.rb CHANGED
@@ -43,11 +43,11 @@ module GitPr
43
43
 
44
44
  client = Octokit::Client.new :login => user, :password => pass
45
45
  begin
46
- authorizations = client.authorizations :headers => headers
47
- auth = authorizations.find { |x| x[:app][:name].match "^#{AUTH_KEY_NAME}" }
48
- unless auth
49
- auth = client.create_authorization(:scopes => ["user", "repo"], :note => AUTH_KEY_NAME, :headers => headers)
50
- end
46
+ hostname = `hostname`.strip!
47
+ auth = client.create_authorization(:scopes => ["user", "repo"],
48
+ :note => "#{AUTH_KEY_NAME} (#{hostname})",
49
+ :fingerprint => "#{hostname} #{Time.now}",
50
+ :headers => headers)
51
51
  rescue Octokit::Unauthorized
52
52
  puts "Invalid username or password."
53
53
  return false
@@ -1,3 +1,3 @@
1
1
  module GitPr
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/git_pr.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "git_pr/git"
1
2
  require "git_pr/github"
2
3
  require "git_pr/pull_request"
3
4
  require "git_pr/version"
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Sharon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tty
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: git
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: netrc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: octokit
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: highline
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.6'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.6'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: ''
@@ -130,7 +130,7 @@ executables:
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
- - .gitignore
133
+ - ".gitignore"
134
134
  - Gemfile
135
135
  - LICENSE.txt
136
136
  - README.md
@@ -139,6 +139,7 @@ files:
139
139
  - git_pr.gemspec
140
140
  - lib/git_pr.rb
141
141
  - lib/git_pr/diff.rb
142
+ - lib/git_pr/git.rb
142
143
  - lib/git_pr/github.rb
143
144
  - lib/git_pr/merge.rb
144
145
  - lib/git_pr/pull_request.rb
@@ -153,17 +154,17 @@ require_paths:
153
154
  - lib
154
155
  required_ruby_version: !ruby/object:Gem::Requirement
155
156
  requirements:
156
- - - '>='
157
+ - - ">="
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  required_rubygems_version: !ruby/object:Gem::Requirement
160
161
  requirements:
161
- - - '>='
162
+ - - ">="
162
163
  - !ruby/object:Gem::Version
163
164
  version: '0'
164
165
  requirements: []
165
166
  rubyforge_project:
166
- rubygems_version: 2.0.14
167
+ rubygems_version: 2.4.8
167
168
  signing_key:
168
169
  specification_version: 4
169
170
  summary: A tool for listing and merging GitHub pull requests.