git_reflow 0.9.3 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,29 +1,47 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.9.3)
4
+ git_reflow (0.9.7)
5
5
  bundler (>= 1.10.0)
6
6
  codenamev_bitbucket_api (= 0.4.1)
7
- colorize (>= 0.7.0)
8
- github_api (= 0.18.2)
7
+ colorize (>= 0.8.1)
8
+ github_api (= 0.19)
9
9
  highline
10
10
  httpclient
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (6.0.3.1)
15
+ activesupport (6.1.3)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- zeitwerk (~> 2.2, >= 2.2.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
21
21
  addressable (2.7.0)
22
22
  public_suffix (>= 2.0.2, < 5.0)
23
- appraisal (2.2.0)
23
+ appraisal (2.4.0)
24
24
  bundler
25
25
  rake
26
26
  thor (>= 0.14.0)
27
+ async (1.28.9)
28
+ console (~> 1.10)
29
+ nio4r (~> 2.3)
30
+ timers (~> 4.1)
31
+ async-http (0.54.1)
32
+ async (~> 1.25)
33
+ async-io (~> 1.28)
34
+ async-pool (~> 0.2)
35
+ protocol-http (~> 0.21.0)
36
+ protocol-http1 (~> 0.13.0)
37
+ protocol-http2 (~> 0.14.0)
38
+ async-http-faraday (0.9.0)
39
+ async-http (~> 0.42)
40
+ faraday
41
+ async-io (1.30.2)
42
+ async (~> 1.14)
43
+ async-pool (0.3.5)
44
+ async (~> 1.25)
27
45
  byebug (11.1.3)
28
46
  chronic (0.10.2)
29
47
  codenamev_bitbucket_api (0.4.1)
@@ -33,28 +51,36 @@ GEM
33
51
  multi_json (< 2.0)
34
52
  nokogiri (>= 1.5.2)
35
53
  simple_oauth (>= 0.3.0)
36
- coderay (1.1.2)
54
+ coderay (1.1.3)
37
55
  colorize (0.8.1)
38
- concurrent-ruby (1.1.6)
39
- crack (0.4.3)
40
- safe_yaml (~> 1.0.0)
56
+ concurrent-ruby (1.1.8)
57
+ console (1.10.1)
58
+ fiber-local
59
+ crack (0.4.5)
60
+ rexml
41
61
  descendants_tracker (0.0.4)
42
62
  thread_safe (~> 0.3, >= 0.3.1)
43
- diff-lcs (1.3)
44
- faraday (0.17.3)
63
+ diff-lcs (1.4.4)
64
+ faraday (1.3.0)
65
+ faraday-net_http (~> 1.0)
45
66
  multipart-post (>= 1.2, < 3)
67
+ ruby2_keywords
46
68
  faraday-http-cache (2.2.0)
47
69
  faraday (>= 0.8)
48
- faraday_middleware (0.14.0)
49
- faraday (>= 0.7.4, < 1.0)
50
- github_api (0.18.2)
70
+ faraday-net_http (1.0.1)
71
+ faraday_middleware (1.2.0)
72
+ faraday (~> 1.0)
73
+ fiber-local (1.0.0)
74
+ github_api (0.19.0)
51
75
  addressable (~> 2.4)
52
76
  descendants_tracker (~> 0.0.4)
53
- faraday (~> 0.8)
77
+ faraday (>= 0.8, < 2)
54
78
  hashie (~> 3.5, >= 3.5.2)
55
79
  oauth2 (~> 1.0)
56
- github_changelog_generator (1.15.2)
80
+ github_changelog_generator (1.16.1)
57
81
  activesupport
82
+ async (>= 1.25.0)
83
+ async-http-faraday
58
84
  faraday-http-cache
59
85
  multi_json
60
86
  octokit (~> 4.6)
@@ -65,81 +91,95 @@ GEM
65
91
  hashie (3.6.0)
66
92
  highline (2.0.3)
67
93
  httpclient (2.8.3)
68
- i18n (1.8.2)
94
+ i18n (1.8.9)
69
95
  concurrent-ruby (~> 1.0)
70
- jwt (2.2.1)
96
+ jwt (2.3.0)
71
97
  method_source (1.0.0)
72
- mini_portile2 (2.4.0)
73
- minitest (5.14.1)
74
- multi_json (1.14.1)
98
+ mini_portile2 (2.7.1)
99
+ minitest (5.14.4)
100
+ multi_json (1.15.0)
75
101
  multi_xml (0.6.0)
76
102
  multipart-post (2.1.1)
77
- nokogiri (1.10.9)
78
- mini_portile2 (~> 2.4.0)
79
- oauth2 (1.4.4)
80
- faraday (>= 0.8, < 2.0)
103
+ nio4r (2.5.7)
104
+ nokogiri (1.13.1)
105
+ mini_portile2 (~> 2.7.0)
106
+ racc (~> 1.4)
107
+ oauth2 (1.4.9)
108
+ faraday (>= 0.17.3, < 3.0)
81
109
  jwt (>= 1.0, < 3.0)
82
110
  multi_json (~> 1.3)
83
111
  multi_xml (~> 0.5)
84
112
  rack (>= 1.2, < 3)
85
- octokit (4.18.0)
113
+ octokit (4.20.0)
86
114
  faraday (>= 0.9)
87
115
  sawyer (~> 0.8.0, >= 0.5.3)
116
+ protocol-hpack (1.4.2)
117
+ protocol-http (0.21.0)
118
+ protocol-http1 (0.13.2)
119
+ protocol-http (~> 0.19)
120
+ protocol-http2 (0.14.2)
121
+ protocol-hpack (~> 1.4)
122
+ protocol-http (~> 0.18)
88
123
  pry (0.13.1)
89
124
  coderay (~> 1.1)
90
125
  method_source (~> 1.0)
91
- pry-byebug (3.9.0)
92
- byebug (~> 11.0)
93
- pry (~> 0.13.0)
94
- public_suffix (4.0.5)
95
- rack (2.2.2)
126
+ public_suffix (4.0.6)
127
+ racc (1.6.0)
128
+ rack (2.2.3)
96
129
  rainbow (3.0.0)
97
- rake (13.0.1)
98
- rdoc (6.2.1)
130
+ rake (13.0.3)
131
+ rdoc (6.3.0)
99
132
  retriable (3.1.2)
100
- rspec (3.9.0)
101
- rspec-core (~> 3.9.0)
102
- rspec-expectations (~> 3.9.0)
103
- rspec-mocks (~> 3.9.0)
104
- rspec-core (3.9.2)
105
- rspec-support (~> 3.9.3)
106
- rspec-expectations (3.9.2)
133
+ rexml (3.2.4)
134
+ rspec (3.10.0)
135
+ rspec-core (~> 3.10.0)
136
+ rspec-expectations (~> 3.10.0)
137
+ rspec-mocks (~> 3.10.0)
138
+ rspec-core (3.10.1)
139
+ rspec-support (~> 3.10.0)
140
+ rspec-expectations (3.10.1)
107
141
  diff-lcs (>= 1.2.0, < 2.0)
108
- rspec-support (~> 3.9.0)
109
- rspec-mocks (3.9.1)
142
+ rspec-support (~> 3.10.0)
143
+ rspec-mocks (3.10.2)
110
144
  diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.9.0)
112
- rspec-support (3.9.3)
113
- safe_yaml (1.0.5)
145
+ rspec-support (~> 3.10.0)
146
+ rspec-support (3.10.2)
147
+ ruby2_keywords (0.0.4)
148
+ ruby_jard (0.3.1)
149
+ byebug (>= 9.1, < 12.0)
150
+ pry (~> 0.13.0)
151
+ tty-screen (~> 0.8.1)
114
152
  sawyer (0.8.2)
115
153
  addressable (>= 2.3.5)
116
154
  faraday (> 0.8, < 2.0)
117
155
  simple_oauth (0.3.1)
118
- thor (1.0.1)
156
+ thor (1.1.0)
119
157
  thread_safe (0.3.6)
120
- tzinfo (1.2.7)
121
- thread_safe (~> 0.1)
122
- webmock (3.8.3)
158
+ timers (4.3.3)
159
+ tty-screen (0.8.1)
160
+ tzinfo (2.0.4)
161
+ concurrent-ruby (~> 1.0)
162
+ webmock (3.12.1)
123
163
  addressable (>= 2.3.6)
124
164
  crack (>= 0.3.2)
125
165
  hashdiff (>= 0.4.0, < 2.0.0)
126
166
  wwtd (1.4.0)
127
- zeitwerk (2.3.0)
167
+ zeitwerk (2.4.2)
128
168
 
129
169
  PLATFORMS
130
170
  ruby
131
171
 
132
172
  DEPENDENCIES
133
- appraisal (= 2.2.0)
173
+ appraisal (= 2.4.0)
134
174
  chronic
135
175
  git_reflow!
136
176
  github_changelog_generator
137
- pry-byebug
138
- rake (~> 13.0.1)
177
+ rake (~> 13.0.3)
139
178
  rdoc
140
- rspec (~> 3.9)
179
+ rspec (~> 3.10)
180
+ ruby_jard
141
181
  webmock
142
182
  wwtd (= 1.4)
143
183
 
144
184
  BUNDLED WITH
145
- 2.1.4
185
+ 2.2.4
data/README.md CHANGED
@@ -443,11 +443,15 @@ If the review is done, it's time to merge. Here's what happens:
443
443
 
444
444
  In order to streamline delivery you can set the following git config to:
445
445
 
446
- 1. always clean up the feature branch after the PR is merged
446
+ 1. always clean up the remote feature branch after the PR is merged
447
447
  ```
448
- git config --global --add "reflow.always-cleanup" "true"
448
+ git config --global --add "reflow.always-cleanup-remote" "true"
449
449
  ```
450
- 2. always deliver without further prompt
450
+ 2. always clean up the local feature branch after the PR is merged
451
+ ```
452
+ git config --global --add "reflow.always-cleanup-local" "true"
453
+ ```
454
+ 3. always deliver without further prompt
451
455
  ```
452
456
  git config --global --add "reflow.always-deliver" "true"
453
457
  ```
data/git_reflow.gemspec CHANGED
@@ -19,20 +19,20 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ['lib']
20
20
  s.rdoc_options << '--title' << 'git_reflow' << '-ri'
21
21
 
22
- s.add_development_dependency('appraisal', '2.2.0')
22
+ s.add_development_dependency('appraisal', '2.4.0')
23
23
  s.add_development_dependency('chronic')
24
24
  s.add_development_dependency('github_changelog_generator')
25
- s.add_development_dependency('pry-byebug')
26
- s.add_development_dependency('rake', '~> 13.0.1')
25
+ s.add_development_dependency('ruby_jard')
26
+ s.add_development_dependency('rake', '~> 13.0.3')
27
27
  s.add_development_dependency('rdoc')
28
- s.add_development_dependency('rspec', '~> 3.9')
28
+ s.add_development_dependency('rspec', '~> 3.10')
29
29
  s.add_development_dependency('webmock')
30
30
  s.add_development_dependency('wwtd', '1.4')
31
31
 
32
32
  s.add_dependency('bundler', '>= 1.10.0')
33
33
  s.add_dependency('codenamev_bitbucket_api', '0.4.1')
34
- s.add_dependency('colorize', '>= 0.7.0')
35
- s.add_dependency('github_api', '0.18.2')
34
+ s.add_dependency('colorize', '>= 0.8.1')
35
+ s.add_dependency('github_api', '0.19')
36
36
  s.add_dependency('highline')
37
37
  s.add_dependency('httpclient')
38
38
 
@@ -14,7 +14,7 @@ module GitReflow
14
14
  # @option options [Boolean] :all (false) whether to return all keys for a multi-valued key
15
15
  # @option options [Boolean] :local (false) whether to get the value specific to the current project
16
16
  # @return the value of the git configuration
17
- def get(key, reload: false, all: false, local: false)
17
+ def get(key, reload: false, all: false, local: false, **_other_options)
18
18
  return cached_git_config_value(key) unless reload || cached_git_config_value(key).empty?
19
19
 
20
20
  local = local ? '--local ' : ''
@@ -32,7 +32,7 @@ module GitReflow
32
32
  # @param [String] value The value to set it to
33
33
  # @option options [Boolean] :local (false) whether to set the value specific to the current project
34
34
  # @return the value of the git configuration
35
- def set(key, value, local: false)
35
+ def set(key, value, local: false, **_other_options)
36
36
  value = value.to_s.strip
37
37
  if local
38
38
  GitReflow::Sandbox.run "git config --replace-all #{key} \"#{value}\"", loud: false, blocking: false
@@ -47,7 +47,7 @@ module GitReflow
47
47
  # @option options [Boolean] :value (nil) The value of the key to remove
48
48
  # @option options [Boolean] :local (false) whether to remove the value specific to the current project
49
49
  # @return the result of running the git command
50
- def unset(key, value: nil, local: false)
50
+ def unset(key, value: nil, local: false, **_other_options)
51
51
  value = value.nil? ? '' : "\"#{value}\""
52
52
  if local
53
53
  GitReflow::Sandbox.run "git config --unset-all #{key} #{value}", loud: false, blocking: false
@@ -63,7 +63,7 @@ module GitReflow
63
63
  # @option options [Boolean] :local (false) whether to set the value specific to the current project
64
64
  # @option options [Boolean] :global (false) whether to set the value globaly. if neither local or global is set gitreflow will default to using a configuration file
65
65
  # @return the result of running the git command
66
- def add(key, value, local: false, global: false)
66
+ def add(key, value, local: false, global: false, **_other_options)
67
67
  if global
68
68
  GitReflow::Sandbox.run "git config --global --add #{key} \"#{value}\"", loud: false, blocking: false
69
69
  elsif local
@@ -47,23 +47,29 @@ module GitReflow
47
47
  end
48
48
 
49
49
  def pull_request_template
50
- filenames_to_try = %w[.github/PULL_REQUEST_TEMPLATE.md
51
- .github/PULL_REQUEST_TEMPLATE
52
- PULL_REQUEST_TEMPLATE.md
53
- PULL_REQUEST_TEMPLATE].map do |file|
50
+ custom_template = GitReflow::Config.get('templates.pull-request')
51
+ filenames_to_try = %w[
52
+ .github/PULL_REQUEST_TEMPLATE.md
53
+ .github/PULL_REQUEST_TEMPLATE
54
+ PULL_REQUEST_TEMPLATE.md
55
+ PULL_REQUEST_TEMPLATE
56
+ ].map do |file|
54
57
  "#{git_root_dir}/#{file}"
55
58
  end
59
+ filenames_to_try.unshift(custom_template) unless custom_template.empty?
56
60
 
57
61
  parse_first_matching_template_file(filenames_to_try)
58
62
  end
59
63
 
60
64
  def merge_commit_template
65
+ custom_template = GitReflow::Config.get('templates.merge-commit')
61
66
  filenames_to_try = %w[.github/MERGE_COMMIT_TEMPLATE.md
62
67
  .github/MERGE_COMMIT_TEMPLATE
63
68
  MERGE_COMMIT_TEMPLATE.md
64
69
  MERGE_COMMIT_TEMPLATE].map do |file|
65
70
  "#{git_root_dir}/#{file}"
66
71
  end
72
+ filenames_to_try.unshift(custom_template) unless custom_template.empty?
67
73
 
68
74
  parse_first_matching_template_file(filenames_to_try)
69
75
  end
@@ -24,8 +24,18 @@ module GitReflow
24
24
  base: options[:base]))
25
25
  end
26
26
 
27
- def self.find_open(to: 'master', from: GitReflow.git_server.class.current_branch)
28
- matching_pull = GitReflow.git_server.connection.pull_requests.all(GitReflow.remote_user, GitReflow.remote_repo_name, base: to, head: "#{GitReflow.remote_user}:#{from}", state: 'open').first
27
+ def self.find_open(options = {})
28
+ options[:to] ||= 'master'
29
+ options[:from] ||= GitReflow.git_server.class.current_branch
30
+
31
+ matching_pull = GitReflow.git_server.connection.pull_requests.all(
32
+ GitReflow.remote_user,
33
+ GitReflow.remote_repo_name,
34
+ base: options[:to],
35
+ head: "#{GitReflow.remote_user}:#{options[:from]}",
36
+ state: 'open'
37
+ ).first
38
+
29
39
  if matching_pull
30
40
  self.new matching_pull
31
41
  end
@@ -147,13 +157,19 @@ module GitReflow
147
157
  GitReflow.run_command_with_label "git pull origin #{self.base_branch_name}"
148
158
  GitReflow.say "Pull request ##{self.number} successfully merged.", :success
149
159
 
150
- if cleanup_feature_branch?
151
- GitReflow.run_command_with_label "git push origin :#{self.feature_branch_name}"
160
+ if cleanup_remote_feature_branch?
161
+ GitReflow.run_command_with_label "git push origin :#{self.feature_branch_name}", blocking: false
162
+ else
163
+ GitReflow.say "Skipped. Remote feature branch #{self.feature_branch_name} left in tact."
164
+ end
165
+
166
+ if cleanup_local_feature_branch?
152
167
  GitReflow.run_command_with_label "git branch -D #{self.feature_branch_name}"
153
- GitReflow.say "Nice job buddy."
154
168
  else
155
- cleanup_failure_message
169
+ GitReflow.say "Skipped. Local feature branch #{self.feature_branch_name} left in tact."
156
170
  end
171
+
172
+ GitReflow.say "Nice job buddy."
157
173
  else
158
174
  GitReflow.say merge_response.to_s, :deliver_halted
159
175
  GitReflow.say "There were problems commiting your feature... please check the errors above and try again.", :error
@@ -84,8 +84,9 @@ module GitReflow
84
84
  end
85
85
 
86
86
  def authenticate(options = {silent: false})
87
- self.class.user = options[:user]
88
- if self.class.user.empty?
87
+ if !options[:user].to_s.empty?
88
+ self.class.user = options[:user]
89
+ elsif self.class.user.empty?
89
90
  self.class.user = ask("Please enter your GitHub username: ")
90
91
  end
91
92
 
@@ -178,7 +178,21 @@ module GitReflow
178
178
  end
179
179
 
180
180
  def cleanup_feature_branch?
181
- GitReflow::Config.get('reflow.always-cleanup') == "true" || (ask "Would you like to push this branch to your remote repo and cleanup your feature branch? ") =~ /^y/i
181
+ cleanup_local_feature_branch? || cleanup_remote_feature_branch?
182
+ end
183
+
184
+ def cleanup_local_feature_branch?
185
+ # backwards compat
186
+ always_cleanup_local = GitReflow::Config.get('reflow.always-cleanup').to_s
187
+ always_cleanup_local = GitReflow::Config.get('reflow.always-cleanup-local') if always_cleanup_local.empty?
188
+ always_cleanup_local == "true" || (ask "Would you like to cleanup your local feature branch? ") =~ /^y/i
189
+ end
190
+
191
+ def cleanup_remote_feature_branch?
192
+ # backwards compat
193
+ always_cleanup_remote = GitReflow::Config.get('reflow.always-cleanup').to_s
194
+ always_cleanup_remote = GitReflow::Config.get('reflow.always-cleanup-remote') if always_cleanup_remote.empty?
195
+ always_cleanup_remote == "true" || (ask "Would you like to cleanup your remote feature branch? ") =~ /^y/i
182
196
  end
183
197
 
184
198
  def deliver?
@@ -1,3 +1,3 @@
1
1
  module GitReflow
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.7"
3
3
  end
@@ -132,7 +132,7 @@ module GitReflow
132
132
  @workflows
133
133
  end
134
134
 
135
- # Creates a singleton method on the inlcuded class
135
+ # Creates a singleton method on the included class
136
136
  #
137
137
  # This method will take any number of keyword parameters. If @defaults keyword is provided, and the given
138
138
  # key(s) in the defaults are not provided as keyword parameters, then it will use the value given in the
@@ -157,7 +157,8 @@ module GitReflow
157
157
  self.commands[name] = params
158
158
  self.command_docs[name] = params
159
159
 
160
- self.define_singleton_method(name) do |**args|
160
+ logger.debug "adding new command '#{name}' with #{defaults.inspect}"
161
+ self.define_singleton_method(name) do |args = {}|
161
162
  args_with_defaults = {}
162
163
  args.each do |name, value|
163
164
  if "#{value}".length <= 0 && !defaults[name].nil?
@@ -230,7 +231,7 @@ module GitReflow
230
231
  end
231
232
  end
232
233
 
233
- # Creates a singleton method on the inlcuded class
234
+ # Creates a singleton method on the included class
234
235
  #
235
236
  # This method updates the help text associated with the provided command.
236
237
  #
@@ -310,13 +311,19 @@ module GitReflow
310
311
  opts.separator "COMMAND OPTIONS:" if docs[:flags].any? || docs[:switches].any?
311
312
 
312
313
  self.commands[name][:flags].each do |flag_name, flag_default|
313
- opts.on("-#{flag_name[0]}", "--#{flag_name} #{flag_name.upcase}", command_docs[name][:flags][flag_name]) do |f|
314
+ # There is a bug in Ruby that will not parse the flag value if no
315
+ # help text is provided. Fallback to the flag name.
316
+ flag_help = command_docs[name][:flags][flag_name] || flag_name
317
+ opts.on("-#{flag_name[0]}", "--#{flag_name} #{flag_name.upcase}", flag_help) do |f|
314
318
  options[kebab_to_underscore(flag_name)] = f || flag_default
315
319
  end
316
320
  end
317
321
 
318
322
  self.commands[name][:switches].each do |switch_name, switch_default|
319
- opts.on("-#{switch_name[0]}", "--[no-]#{switch_name}", command_docs[name][:switches][switch_name]) do |s|
323
+ # There is a bug in Ruby that will not parse the switch value if no
324
+ # help text is provided. Fallback to the switch name.
325
+ switch_help = command_docs[name][:switches][switch_name] || switch_name
326
+ opts.on("-#{switch_name[0]}", "--[no-]#{switch_name}", switch_help) do |s|
320
327
  options[kebab_to_underscore(switch_name)] = s || switch_default
321
328
  end
322
329
  end