git_reflow 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c3ed99e025542264cc8078d207d8d15fc58d0463
4
- data.tar.gz: 4fbcf83566de80f9dfc57b599082ea342f9deb38
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTU5NWIzMGM1MTFmYTQ5NDVmZDQ1MDFkNjViZjhmMzVmZTg5YTVjMQ==
5
+ data.tar.gz: !binary |-
6
+ ZDUzNmM2NTcxOGYxYzE3YWQ0YzA3YjVkMjMyZTQ1ZTZhYWE0ZGU2Mg==
5
7
  SHA512:
6
- metadata.gz: f22d231cadc58f7c2e4fb29bf54a6a4e80fd8e3198ba446f076cecabbd8dee652a326622e2646f9102d45702268348fe4657444bdce45cf58929c553905446b6
7
- data.tar.gz: c21635b405f54e938768cb754af59d7921b1440e0cc4ac9391ead3cfeaaa17b61097709cfab8555a40f3e504db01f9419622bf9bbd23570723e47f504de5a5b6
8
+ metadata.gz: !binary |-
9
+ OTdmMDIwNGQzYzA3ZmU0NTZkN2IxNDQyNmVkZTgzOWE1NTIzMDcwZDI2NzNj
10
+ NGJhZDRkMTgwN2U5MzA2MTQzODY0ODgwNGE3YjUyMTVhYzAzZmY0OTcwOWMw
11
+ MjM3NzJkMTE4NmI5OTRlNjNhODVhYTI1ZmUzNzRmYmQ3MWQzNjg=
12
+ data.tar.gz: !binary |-
13
+ YTJkYzk3OTI5ZDFjOTI5MGU5NjA2NGVhYzRiYjNmZWE2OWFmZWY4YzVlZTgy
14
+ YzM1ZDBlNzBmMDY3ZGY4NzNiMzZmNTVmOWZlZWVmNDVmYTJjNTNiZjk3MjIx
15
+ NWMyOTk5MzRjNGM3MTU1MjM1ZTVhMmE3YWM2MTIxYTBlODBiMGQ=
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,49 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.3.2)
5
- colorize (= 0.5.8)
6
- github_api (= 0.7.0)
7
- gli (= 2.1.0)
4
+ git_reflow (0.3.3)
5
+ colorize (= 0.6.0)
6
+ github_api (= 0.10.2)
7
+ gli (= 2.8.1)
8
8
  highline
9
9
  httpclient
10
10
 
11
11
  GEM
12
- remote: http://rubygems.org/
12
+ remote: https://rubygems.org/
13
13
  specs:
14
- colorize (0.5.8)
15
- faraday (0.8.4)
16
- multipart-post (~> 1.1)
14
+ addressable (2.3.5)
15
+ colorize (0.6.0)
16
+ faraday (0.8.8)
17
+ multipart-post (~> 1.2.0)
17
18
  git (1.2.5)
18
- github_api (0.7.0)
19
- faraday (~> 0.8.1)
20
- hashie (~> 1.2.0)
21
- multi_json (~> 1.3)
22
- nokogiri (~> 1.5.2)
19
+ github_api (0.10.2)
20
+ addressable
21
+ faraday (~> 0.8.7)
22
+ hashie (>= 1.2)
23
+ multi_json (~> 1.4)
24
+ nokogiri (~> 1.6.0)
23
25
  oauth2
24
- gli (2.1.0)
25
- hashie (1.2.0)
26
- highline (1.6.18)
26
+ gli (2.8.1)
27
+ hashie (2.0.5)
28
+ highline (1.6.19)
27
29
  httpauth (0.2.0)
28
- httpclient (2.2.7)
30
+ httpclient (2.3.4.1)
29
31
  jeweler (1.8.4)
30
32
  bundler (~> 1.0)
31
33
  git (>= 1.2.5)
32
34
  rake
33
35
  rdoc
34
36
  json (1.7.5)
35
- jwt (0.1.5)
36
- multi_json (>= 1.0)
37
- multi_json (1.7.2)
38
- multipart-post (1.1.5)
39
- nokogiri (1.5.6)
40
- oauth2 (0.8.0)
37
+ jwt (0.1.8)
38
+ multi_json (>= 1.5)
39
+ mini_portile (0.5.1)
40
+ multi_json (1.8.2)
41
+ multi_xml (0.5.5)
42
+ multipart-post (1.2.0)
43
+ nokogiri (1.6.0)
44
+ mini_portile (~> 0.5.0)
45
+ oauth2 (0.9.2)
41
46
  faraday (~> 0.8)
42
- httpauth (~> 0.1)
47
+ httpauth (~> 0.2)
43
48
  jwt (~> 0.1.4)
44
49
  multi_json (~> 1.0)
50
+ multi_xml (~> 0.5)
45
51
  rack (~> 1.2)
46
- rack (1.4.1)
52
+ rack (1.5.2)
47
53
  rake (0.9.2.2)
48
54
  rdoc (3.12)
49
55
  json (~> 1.4)
data/README.rdoc CHANGED
@@ -51,8 +51,6 @@ or
51
51
  $ gem install git_reflow
52
52
 
53
53
  === Setup
54
- git reflow setup
55
-
56
54
  On your first install, you'll need to setup your Github credentials. These are used only to get an oauth token that's stored in your global git config.
57
55
  We use the Github credentials so we can create pull requests from the command line.
58
56
 
@@ -68,6 +66,22 @@ It looks like this:
68
66
 
69
67
  This is safe to run multiple times. We don't care.
70
68
 
69
+ === Usage with Github Enterprise
70
+ To use GitReflow with a GitHub Enterprise account, there are some additional switches available to the GitReflow setup command. You should be able to use GitReflow for both your Enterprise and non-Enterprise repositories. Because of this, there are a few scenarios that may apply to your usage of GitReflow:
71
+
72
+ You use a GitHub Enterprise account for the majority of your repositories:
73
+ git reflow setup --enterprise
74
+ After this, anytime you want to use GitReflow with project that uses a regular GitHub account:
75
+ cd replace_with_your_non_enterprise_project_path
76
+ git reflow setup --local
77
+ This will setup your project's git config with the OAuth token generated from the credentials you provide
78
+
79
+ If you only use GitHub Enterprise for a select few repositories, you'll first want to setup GitReflow as normal:
80
+ git reflow setup
81
+ Then for your Enterprise projects, you have to setup GitReflow for each one:
82
+ cd replace_with_your_enterprise_project_path
83
+ git reflow setup --enterprise --local
84
+
71
85
  === Starting a feature branch
72
86
  git reflow start
73
87
 
data/git_reflow.gemspec CHANGED
@@ -24,11 +24,11 @@ spec = Gem::Specification.new do |s|
24
24
  s.add_development_dependency('rdoc')
25
25
  s.add_development_dependency('jeweler')
26
26
 
27
- s.add_dependency('colorize', '0.5.8')
28
- s.add_dependency('gli', '2.1.0')
27
+ s.add_dependency('colorize', '0.6.0')
28
+ s.add_dependency('gli', '2.8.1')
29
29
  s.add_dependency('highline')
30
30
  s.add_dependency('httpclient')
31
- s.add_dependency('github_api', '0.7.0')
31
+ s.add_dependency('github_api', '0.10.2')
32
32
 
33
33
  s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
34
34
  end
data/lib/git_reflow.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'git_reflow/version.rb'
3
2
  require 'open-uri'
4
3
  require "highline/import"
5
4
  require 'httpclient'
@@ -7,21 +6,54 @@ require 'github_api'
7
6
  require 'json/pure'
8
7
  require 'colorize'
9
8
 
9
+ require 'git_reflow/version.rb' unless defined?(GitReflow::VERSION)
10
+
10
11
  module GitReflow
11
12
  extend self
12
13
 
13
- LGTM = /lgtm|looks good to me|:\+1:|:thumbsup:/i
14
+ LGTM = /lgtm|looks good to me|:\+1:|:thumbsup:|:shipit:/i
15
+
16
+ def setup(options = {})
17
+ project_only = options.delete(:project_only)
18
+ using_enterprise = options.delete(:enterprise)
19
+ gh_site_url = github_site_url
20
+ gh_api_endpoint = github_api_endpoint
21
+
22
+ if using_enterprise
23
+ gh_site_url = ask("Please enter your Enterprise site URL (e.g. https://github.company.com):")
24
+ gh_api_endpoint = ask("Please enter your Enterprise API endpoint (e.g. https://github.company.com/api/v3):")
25
+ end
26
+
27
+ if project_only
28
+ set_github_site_url(gh_site_url, local: true)
29
+ set_github_api_endpoint(gh_api_endpoint, local: true)
30
+ else
31
+ set_github_site_url(gh_site_url)
32
+ set_github_api_endpoint(gh_api_endpoint)
33
+ end
14
34
 
15
- def setup
16
35
  gh_user = ask("Please enter your GitHub username: ")
17
36
  gh_password = ask("Please enter your GitHub password (we do NOT store this): ") { |q| q.echo = false }
18
37
 
19
38
  begin
20
- github = Github.new :basic_auth => "#{gh_user}:#{gh_password}"
39
+
40
+ github = Github.new do |config|
41
+ config.basic_auth = "#{gh_user}:#{gh_password}"
42
+ config.endpoint = GitReflow.github_api_endpoint
43
+ config.site = GitReflow.github_site_url
44
+ config.adapter = :net_http
45
+ config.ssl = {:verify => false}
46
+ end
47
+
21
48
  authorization = github.oauth.create 'scopes' => ['repo']
22
49
  oauth_token = authorization[:token]
23
- set_oauth_token(oauth_token)
24
- rescue
50
+
51
+ if project_only
52
+ set_oauth_token(oauth_token, local: true)
53
+ else
54
+ set_oauth_token(oauth_token)
55
+ end
56
+ rescue StandardError => e
25
57
  puts "\nInvalid username or password"
26
58
  else
27
59
  puts "\nYour GitHub account was successfully setup!"
@@ -48,10 +80,10 @@ module GitReflow
48
80
  begin
49
81
  puts push_current_branch
50
82
  pull_request = github.pull_requests.create(remote_user, remote_repo_name,
51
- 'title' => options['title'],
52
- 'body' => options['body'],
53
- 'head' => "#{remote_user}:#{current_branch}",
54
- 'base' => options['base'])
83
+ 'title' => options['title'],
84
+ 'body' => options['body'],
85
+ 'head' => "#{remote_user}:#{current_branch}",
86
+ 'base' => options['base'])
55
87
 
56
88
  puts "Successfully created pull request ##{pull_request.number}: #{pull_request.title}\nPull Request URL: #{pull_request.html_url}\n"
57
89
  ask_to_open_in_browser(pull_request.html_url)
@@ -86,9 +118,9 @@ module GitReflow
86
118
  has_comments = has_pull_request_comments?(existing_pull_request)
87
119
 
88
120
  # if there any comment_authors left, then they haven't given a lgtm after the last commit
89
- if (has_comments and open_comment_authors.empty?) or options['skip-lgtm']
121
+ if (has_comments and open_comment_authors.empty?) or options['skip_lgtm']
90
122
  lgtm_authors = comment_authors_for_pull_request(existing_pull_request, :with => LGTM)
91
- commit_message = existing_pull_request[:body] || get_first_commit_message
123
+ commit_message = "#{existing_pull_request[:title]}\n#{(existing_pull_request[:body] || get_first_commit_message)}"
92
124
  puts "Merging pull request ##{existing_pull_request.number}: '#{existing_pull_request.title}', from '#{existing_pull_request.head.label}' into '#{existing_pull_request.base.label}'"
93
125
 
94
126
  update_destination(options['base'])
@@ -97,15 +129,16 @@ module GitReflow
97
129
  :pull_request_number => existing_pull_request.number,
98
130
  :message => "\nCloses ##{existing_pull_request.number}\n\nLGTM given by: @#{lgtm_authors.join(', @')}\n")
99
131
  append_to_squashed_commit_message(commit_message)
132
+ puts "git commit".colorize(:green)
100
133
  committed = system('git commit')
101
134
 
102
135
  if committed
103
136
  puts "Merge complete!"
104
137
  deploy_and_cleanup = ask "Would you like to push this branch to your remote repo and cleanup your feature branch? "
105
138
  if deploy_and_cleanup =~ /^y/i
106
- puts `git push origin #{options['base']}`
107
- puts `git push origin :#{feature_branch}`
108
- puts `git branch -D #{feature_branch}`
139
+ run_command_with_label "git push origin #{options['base']}"
140
+ run_command_with_label "git push origin :#{feature_branch}"
141
+ run_command_with_label "git branch -D #{feature_branch}"
109
142
  puts "Nice job buddy."
110
143
  end
111
144
  else
@@ -126,10 +159,40 @@ module GitReflow
126
159
  end
127
160
 
128
161
  def github
129
- @github ||= Github.new :oauth_token => get_oauth_token
162
+ @github ||= Github.new do |config|
163
+ config.oauth_token = GitReflow.github_oauth_token
164
+ config.endpoint = GitReflow.github_api_endpoint
165
+ config.site = GitReflow.github_site_url
166
+ end
167
+ end
168
+
169
+ def github_api_endpoint
170
+ endpoint = `git config --get github.endpoint`.strip
171
+ (endpoint.length > 0) ? endpoint : Github::Configuration::DEFAULT_ENDPOINT
130
172
  end
131
173
 
132
- def get_oauth_token
174
+ def set_github_api_endpoint(api_endpoint, options = {local: false})
175
+ if options[:local]
176
+ `git config --replace-all github.endpoint #{api_endpoint}`
177
+ else
178
+ `git config --global --replace-all github.endpoint #{api_endpoint}`
179
+ end
180
+ end
181
+
182
+ def github_site_url
183
+ site_url = `git config --get github.site`.strip
184
+ (site_url.length > 0) ? site_url : Github::Configuration::DEFAULT_SITE
185
+ end
186
+
187
+ def set_github_site_url(site_url, options = {local: false})
188
+ if options[:local]
189
+ `git config --replace-all github.site #{site_url}`
190
+ else
191
+ `git config --global --replace-all github.site #{site_url}`
192
+ end
193
+ end
194
+
195
+ def github_oauth_token
133
196
  `git config --get github.oauth-token`.strip
134
197
  end
135
198
 
@@ -155,32 +218,35 @@ module GitReflow
155
218
  `git log --pretty=format:"%s" --no-merges -n 1`.strip
156
219
  end
157
220
 
158
-
159
- def set_oauth_token(oauth_token)
160
- `git config --global --replace-all github.oauth-token #{oauth_token}`
221
+ def set_oauth_token(oauth_token, options = {})
222
+ if options.delete(:local)
223
+ `git config --replace-all github.oauth-token #{oauth_token}`
224
+ else
225
+ `git config --global --replace-all github.oauth-token #{oauth_token}`
226
+ end
161
227
  end
162
228
 
163
229
  def push_current_branch
164
- `git push origin #{current_branch}`
230
+ run_command_with_label "git push origin #{current_branch}"
165
231
  end
166
232
 
167
233
  def fetch_destination(destination_branch)
168
- `git fetch origin #{destination_branch}`
234
+ run_command_with_label "git fetch origin #{destination_branch}"
169
235
  end
170
236
 
171
237
  def update_destination(destination_branch)
172
238
  origin_branch = current_branch
173
- `git checkout #{destination_branch}`
174
- puts `git pull origin #{destination_branch}`
175
- `git checkout #{origin_branch}`
239
+ run_command_with_label "git checkout #{destination_branch}"
240
+ run_command_with_label "git pull origin #{destination_branch}"
241
+ run_command_with_label "git checkout #{origin_branch}"
176
242
  end
177
243
 
178
244
  def merge_feature_branch(options = {})
179
245
  options[:destination_branch] ||= 'master'
180
246
  message = options[:message] || "\nCloses ##{options[:pull_request_number]}\n"
181
247
 
182
- `git checkout #{options[:destination_branch]}`
183
- puts `git merge --squash #{options[:feature_branch]}`
248
+ run_command_with_label "git checkout #{options[:destination_branch]}"
249
+ run_command_with_label "git merge --squash #{options[:feature_branch]}"
184
250
  # append pull request number to commit message
185
251
  append_to_squashed_commit_message(message)
186
252
  end
@@ -204,10 +270,10 @@ module GitReflow
204
270
  end
205
271
 
206
272
  def pull_request_comments(pull_request)
207
- comments = github.issues.comments.all remote_user, remote_repo_name, pull_request.number
208
- review_comments = github.pull_requests.comments.all remote_user, remote_repo_name, pull_request.number
273
+ comments = github.issues.comments.all remote_user, remote_repo_name, issue_id: pull_request.number
274
+ review_comments = github.pull_requests.comments.all remote_user, remote_repo_name, request_id: pull_request.number
209
275
 
210
- review_comments + comments
276
+ review_comments.to_a + comments.to_a
211
277
  end
212
278
 
213
279
  def has_pull_request_comments?(pull_request)
@@ -297,4 +363,10 @@ module GitReflow
297
363
  end
298
364
  end
299
365
  end
366
+
367
+ def run_command_with_label(command, options = {})
368
+ label_color = options.delete(:color) || :green
369
+ puts command.colorize(label_color)
370
+ puts `#{command}`
371
+ end
300
372
  end
@@ -7,7 +7,7 @@ command :deliver do |c|
7
7
  c.desc 'merge your feature branch down to your base branch, and cleanup your feature branch'
8
8
  c.arg_name 'base_branch - the branch you want to merge into'
9
9
  c.action do |global_options,options,args|
10
- deliver_options = {'base' => nil, 'head' => nil}
10
+ deliver_options = {'base' => nil, 'head' => nil, 'skip_lgtm' => options[:'skip-lgtm']}
11
11
  case args.length
12
12
  when 2
13
13
  deliver_options['base'] = args[0]
@@ -15,7 +15,6 @@ command :deliver do |c|
15
15
  when 1
16
16
  deliver_options['base'] = args[0]
17
17
  end
18
- deliver_options.merge({'skip_lgtm' => options[:'skip-lgtm']})
19
18
  GitReflow.deliver deliver_options
20
19
  end
21
20
  end
@@ -3,23 +3,18 @@ arg_name 'Describe arguments to review here'
3
3
  command :review do |c|
4
4
  c.desc 'push your latest feature branch changes to your remote repo and create a pull request against the destination branch'
5
5
  c.arg_name '[destination_branch] - the branch you want to merge your feature branch into'
6
+ c.flag [:t, :title], default_value: 'last commit message'
7
+ c.flag [:m, :message], default_value: 'title'
6
8
  c.action do |global_options,options,args|
7
- review_options = {'base' => nil, 'title' => nil, 'body' => nil}
8
- case args.length
9
- when 3
10
- review_options['base'] = args[0]
11
- review_options['title'] = args[1]
12
- review_options['body'] = args[2]
13
- when 2
14
- review_options['base'] = args[0]
15
- review_options['title'] = args[1]
16
- review_options['body'] = review_options['title']
17
- when 1
18
- review_options['base'] = args[0]
19
- review_options['title'] = review_options['body'] = GitReflow.get_first_commit_message
20
- else
21
- review_options['title'] = review_options['body'] = GitReflow.get_first_commit_message
22
- end
9
+ review_options = {
10
+ 'base' => args[0],
11
+ 'title' => global_options[:title],
12
+ 'body' => global_options[:message]
13
+ }
14
+
15
+ review_options['title'] ||= GitReflow.get_first_commit_message
16
+ review_options['body'] ||= review_options['title']
17
+
23
18
  GitReflow.review review_options
24
19
  end
25
20
  end
@@ -1,7 +1,9 @@
1
1
  desc 'Setup your GitHub account'
2
2
  command :setup do |c|
3
3
  c.desc 'sets up your api token with GitHub'
4
+ c.switch [:l, :local], default_value: false, desc: 'setup GitReflow for the current project only'
5
+ c.switch [:e, :enterprise], default_value: false, desc: 'setup GitReflow with a Github Enterprise account'
4
6
  c.action do |global_options, options, args|
5
- GitReflow.setup
7
+ GitReflow.setup({ project_only: options[:local], enterprise: options[:enterprise] })
6
8
  end
7
9
  end
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_reflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentino Stoll
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-25 00:00:00.000000000 Z
13
+ date: 2013-10-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -60,28 +60,28 @@ dependencies:
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.5.8
63
+ version: 0.6.0
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.5.8
70
+ version: 0.6.0
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: gli
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 2.1.0
77
+ version: 2.8.1
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - '='
83
83
  - !ruby/object:Gem::Version
84
- version: 2.1.0
84
+ version: 2.8.1
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: highline
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -116,14 +116,14 @@ dependencies:
116
116
  requirements:
117
117
  - - '='
118
118
  - !ruby/object:Gem::Version
119
- version: 0.7.0
119
+ version: 0.10.2
120
120
  type: :runtime
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - '='
125
125
  - !ruby/object:Gem::Version
126
- version: 0.7.0
126
+ version: 0.10.2
127
127
  description: Git Reflow manages your git workflow.
128
128
  email:
129
129
  - dev@reenhanced.com
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  requirements: []
181
181
  rubyforge_project:
182
- rubygems_version: 2.0.3
182
+ rubygems_version: 2.1.7
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: A better git process