git_reflow 0.9.2 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,113 +1,185 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_reflow (0.9.2)
4
+ git_reflow (0.9.6)
5
5
  bundler (>= 1.10.0)
6
- colorize (>= 0.7.0)
7
- github_api (= 0.18.2)
6
+ codenamev_bitbucket_api (= 0.4.1)
7
+ colorize (>= 0.8.1)
8
+ github_api (= 0.19)
8
9
  highline
9
10
  httpclient
10
- reenhanced_bitbucket_api (= 0.3.2)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
+ activesupport (6.1.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
15
21
  addressable (2.7.0)
16
22
  public_suffix (>= 2.0.2, < 5.0)
17
- appraisal (2.2.0)
23
+ appraisal (2.4.0)
18
24
  bundler
19
25
  rake
20
26
  thor (>= 0.14.0)
21
- byebug (11.0.1)
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)
45
+ byebug (11.1.3)
22
46
  chronic (0.10.2)
23
- coderay (1.1.2)
47
+ codenamev_bitbucket_api (0.4.1)
48
+ faraday (< 2.0)
49
+ faraday_middleware (< 2.0)
50
+ hashie
51
+ multi_json (< 2.0)
52
+ nokogiri (>= 1.5.2)
53
+ simple_oauth (>= 0.3.0)
54
+ coderay (1.1.3)
24
55
  colorize (0.8.1)
25
- crack (0.4.3)
26
- 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
27
61
  descendants_tracker (0.0.4)
28
62
  thread_safe (~> 0.3, >= 0.3.1)
29
- diff-lcs (1.3)
30
- faraday (0.9.2)
63
+ diff-lcs (1.4.4)
64
+ faraday (1.3.0)
65
+ faraday-net_http (~> 1.0)
31
66
  multipart-post (>= 1.2, < 3)
32
- faraday_middleware (0.9.2)
33
- faraday (>= 0.7.4, < 0.10)
34
- github_api (0.18.2)
67
+ ruby2_keywords
68
+ faraday-http-cache (2.2.0)
69
+ faraday (>= 0.8)
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)
35
75
  addressable (~> 2.4)
36
76
  descendants_tracker (~> 0.0.4)
37
- faraday (~> 0.8)
77
+ faraday (>= 0.8, < 2)
38
78
  hashie (~> 3.5, >= 3.5.2)
39
79
  oauth2 (~> 1.0)
40
- hashdiff (1.0.0)
80
+ github_changelog_generator (1.16.1)
81
+ activesupport
82
+ async (>= 1.25.0)
83
+ async-http-faraday
84
+ faraday-http-cache
85
+ multi_json
86
+ octokit (~> 4.6)
87
+ rainbow (>= 2.2.1)
88
+ rake (>= 10.0)
89
+ retriable (~> 3.0)
90
+ hashdiff (1.0.1)
41
91
  hashie (3.6.0)
42
- highline (2.0.2)
92
+ highline (2.0.3)
43
93
  httpclient (2.8.3)
44
- jwt (2.2.1)
45
- method_source (0.9.2)
46
- mini_portile2 (2.4.0)
47
- multi_json (1.13.1)
94
+ i18n (1.8.9)
95
+ concurrent-ruby (~> 1.0)
96
+ jwt (2.3.0)
97
+ method_source (1.0.0)
98
+ mini_portile2 (2.6.1)
99
+ minitest (5.14.4)
100
+ multi_json (1.15.0)
48
101
  multi_xml (0.6.0)
49
102
  multipart-post (2.1.1)
50
- nokogiri (1.10.4)
51
- mini_portile2 (~> 2.4.0)
52
- oauth2 (1.4.1)
53
- faraday (>= 0.8, < 0.16.0)
103
+ nio4r (2.5.7)
104
+ nokogiri (1.12.5)
105
+ mini_portile2 (~> 2.6.1)
106
+ racc (~> 1.4)
107
+ oauth2 (1.4.7)
108
+ faraday (>= 0.8, < 2.0)
54
109
  jwt (>= 1.0, < 3.0)
55
110
  multi_json (~> 1.3)
56
111
  multi_xml (~> 0.5)
57
112
  rack (>= 1.2, < 3)
58
- pry (0.12.2)
59
- coderay (~> 1.1.0)
60
- method_source (~> 0.9.0)
61
- pry-byebug (3.7.0)
62
- byebug (~> 11.0)
63
- pry (~> 0.10)
64
- public_suffix (4.0.1)
65
- rack (2.0.7)
66
- rake (12.3.3)
67
- rdoc (6.2.0)
68
- reenhanced_bitbucket_api (0.3.2)
69
- faraday (~> 0.9.0)
70
- faraday_middleware (~> 0.9.0)
71
- hashie (>= 3.2)
72
- multi_json (>= 1.7.5, < 2.0)
73
- nokogiri (>= 1.5.2)
74
- simple_oauth (>= 0.3.0)
75
- rspec (3.8.0)
76
- rspec-core (~> 3.8.0)
77
- rspec-expectations (~> 3.8.0)
78
- rspec-mocks (~> 3.8.0)
79
- rspec-core (3.8.2)
80
- rspec-support (~> 3.8.0)
81
- rspec-expectations (3.8.4)
113
+ octokit (4.20.0)
114
+ faraday (>= 0.9)
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)
123
+ pry (0.13.1)
124
+ coderay (~> 1.1)
125
+ method_source (~> 1.0)
126
+ public_suffix (4.0.6)
127
+ racc (1.6.0)
128
+ rack (2.2.3)
129
+ rainbow (3.0.0)
130
+ rake (13.0.3)
131
+ rdoc (6.3.0)
132
+ retriable (3.1.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)
82
141
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.8.0)
84
- rspec-mocks (3.8.1)
142
+ rspec-support (~> 3.10.0)
143
+ rspec-mocks (3.10.2)
85
144
  diff-lcs (>= 1.2.0, < 2.0)
86
- rspec-support (~> 3.8.0)
87
- rspec-support (3.8.2)
88
- 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)
152
+ sawyer (0.8.2)
153
+ addressable (>= 2.3.5)
154
+ faraday (> 0.8, < 2.0)
89
155
  simple_oauth (0.3.1)
90
- thor (0.20.3)
156
+ thor (1.1.0)
91
157
  thread_safe (0.3.6)
92
- webmock (3.7.1)
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)
93
163
  addressable (>= 2.3.6)
94
164
  crack (>= 0.3.2)
95
165
  hashdiff (>= 0.4.0, < 2.0.0)
96
166
  wwtd (1.4.0)
167
+ zeitwerk (2.4.2)
97
168
 
98
169
  PLATFORMS
99
170
  ruby
100
171
 
101
172
  DEPENDENCIES
102
- appraisal (= 2.2.0)
173
+ appraisal (= 2.4.0)
103
174
  chronic
104
175
  git_reflow!
105
- pry-byebug
106
- rake (~> 12.3)
176
+ github_changelog_generator
177
+ rake (~> 13.0.3)
107
178
  rdoc
108
- rspec (~> 3.8)
179
+ rspec (~> 3.10)
180
+ ruby_jard
109
181
  webmock
110
182
  wwtd (= 1.4)
111
183
 
112
184
  BUNDLED WITH
113
- 2.0.2
185
+ 2.2.4
data/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  </h1>
5
5
 
6
6
  <p>
7
- <a href="https://circleci.com/gh/reenhanced/git-reflow/tree/master" title="current build status">
8
- <img alt="Circle CI" src="https://circleci.com/gh/reenhanced/gitreflow.svg?style=svg&circle-token=d94825c17c7e33558dc2a82b37afad7b558e5a12">
7
+ <a href="https://actions-badge.atrox.dev/reenhanced/gitreflow/goto?ref=master" title="git workflow">
8
+ <img alt="Git workflow powered by git-reflow" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Freenhanced%2Fgitreflow%2Fbadge%3Fref%3Dmaster&style=flat">
9
9
  </a>
10
10
  <a href="https://github.com/reenhanced/gitreflow" title="git workflow">
11
11
  <img alt="Git workflow powered by git-reflow" src="https://img.shields.io/badge/git--reflow-v0.9.0-blue.svg?style=flat">
@@ -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/Rakefile CHANGED
@@ -1,8 +1,15 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
+ require "github_changelog_generator/task"
4
5
 
5
6
  RSpec::Core::RakeTask.new(:spec)
6
7
 
7
- task :default => :spec
8
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
9
+ config.user = 'reenhanced'
10
+ config.project = 'gitreflow'
11
+ config.since_tag = 'v0.9.2'
12
+ config.future_release = 'master'
13
+ end
8
14
 
15
+ task :default => :spec
data/git_reflow.gemspec CHANGED
@@ -1,38 +1,40 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Ensure we require the local version and not one we might have installed already
2
- require File.join([File.dirname(__FILE__),'lib','git_reflow/version.rb'])
4
+ require File.join([File.dirname(__FILE__), 'lib', 'git_reflow/version.rb'])
3
5
  Gem::Specification.new do |s|
4
- s.name = 'git_reflow'
5
- s.version = GitReflow::VERSION
6
- s.license = 'MIT'
7
- s.authors = ["Valentino Stoll", "Robert Stern", "Nicholas Hance"]
8
- s.email = ["dev@reenhanced.com"]
9
- s.homepage = "http://github.com/reenhanced/gitreflow"
10
- s.summary = "A better git process"
11
- s.description = "Git Reflow manages your git workflow."
12
- s.platform = Gem::Platform::RUBY
13
- s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
14
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
- s.has_rdoc = true
17
- s.bindir = "exe"
18
- s.require_paths = ["lib"]
19
- s.rdoc_options << '--title' << 'git_reflow' << '-ri'
6
+ s.name = 'git_reflow'
7
+ s.version = GitReflow::VERSION
8
+ s.license = 'MIT'
9
+ s.authors = ['Valentino Stoll', 'Robert Stern', 'Nicholas Hance']
10
+ s.email = ['dev@reenhanced.com']
11
+ s.homepage = 'http://github.com/reenhanced/gitreflow'
12
+ s.summary = 'A better git process'
13
+ s.description = 'Git Reflow manages your git workflow.'
14
+ s.platform = Gem::Platform::RUBY
15
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ s.bindir = 'exe'
19
+ s.require_paths = ['lib']
20
+ s.rdoc_options << '--title' << 'git_reflow' << '-ri'
20
21
 
21
- s.add_development_dependency('appraisal', '2.2.0')
22
+ s.add_development_dependency('appraisal', '2.4.0')
22
23
  s.add_development_dependency('chronic')
23
- s.add_development_dependency('pry-byebug')
24
- s.add_development_dependency('rake', "~> 12.3")
24
+ s.add_development_dependency('github_changelog_generator')
25
+ s.add_development_dependency('ruby_jard')
26
+ s.add_development_dependency('rake', '~> 13.0.3')
25
27
  s.add_development_dependency('rdoc')
26
- s.add_development_dependency('rspec', "~> 3.8")
28
+ s.add_development_dependency('rspec', '~> 3.10')
27
29
  s.add_development_dependency('webmock')
28
30
  s.add_development_dependency('wwtd', '1.4')
29
31
 
30
32
  s.add_dependency('bundler', '>= 1.10.0')
31
- s.add_dependency('colorize', '>= 0.7.0')
33
+ s.add_dependency('codenamev_bitbucket_api', '0.4.1')
34
+ s.add_dependency('colorize', '>= 0.8.1')
35
+ s.add_dependency('github_api', '0.19')
32
36
  s.add_dependency('highline')
33
37
  s.add_dependency('httpclient')
34
- s.add_dependency('github_api', '0.18.2')
35
- s.add_dependency('reenhanced_bitbucket_api', '0.3.2')
36
38
 
37
39
  s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
38
40
  end
@@ -7,7 +7,14 @@ module GitReflow
7
7
 
8
8
  module_function
9
9
 
10
- def get(key, reload: false, all: false, local: false)
10
+ # Gets the reqested git configuration variable.
11
+ #
12
+ # @param [String] key The key to get the value(s) for
13
+ # @option options [Boolean] :reload (false) whether to reload the value or use a cached value if available
14
+ # @option options [Boolean] :all (false) whether to return all keys for a multi-valued key
15
+ # @option options [Boolean] :local (false) whether to get the value specific to the current project
16
+ # @return the value of the git configuration
17
+ def get(key, reload: false, all: false, local: false, **_other_options)
11
18
  return cached_git_config_value(key) unless reload || cached_git_config_value(key).empty?
12
19
 
13
20
  local = local ? '--local ' : ''
@@ -19,7 +26,13 @@ module GitReflow
19
26
  cache_git_config_key(key, new_value)
20
27
  end
21
28
 
22
- def set(key, value, local: false)
29
+ # Sets the reqested git configuration variable.
30
+ #
31
+ # @param [String] key The key to set the value for
32
+ # @param [String] value The value to set it to
33
+ # @option options [Boolean] :local (false) whether to set the value specific to the current project
34
+ # @return the value of the git configuration
35
+ def set(key, value, local: false, **_other_options)
23
36
  value = value.to_s.strip
24
37
  if local
25
38
  GitReflow::Sandbox.run "git config --replace-all #{key} \"#{value}\"", loud: false, blocking: false
@@ -28,7 +41,13 @@ module GitReflow
28
41
  end
29
42
  end
30
43
 
31
- def unset(key, value: nil, local: false)
44
+ # Remove values of the reqested git configuration variable.
45
+ #
46
+ # @param [String] key The key to remove
47
+ # @option options [Boolean] :value (nil) The value of the key to remove
48
+ # @option options [Boolean] :local (false) whether to remove the value specific to the current project
49
+ # @return the result of running the git command
50
+ def unset(key, value: nil, local: false, **_other_options)
32
51
  value = value.nil? ? '' : "\"#{value}\""
33
52
  if local
34
53
  GitReflow::Sandbox.run "git config --unset-all #{key} #{value}", loud: false, blocking: false
@@ -37,7 +56,14 @@ module GitReflow
37
56
  end
38
57
  end
39
58
 
40
- def add(key, value, local: false, global: false)
59
+ # Adds a new git configuration variable.
60
+ #
61
+ # @param [String] key The new key to set the value for
62
+ # @param [String] value The value to set it to
63
+ # @option options [Boolean] :local (false) whether to set the value specific to the current project
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
+ # @return the result of running the git command
66
+ def add(key, value, local: false, global: false, **_other_options)
41
67
  if global
42
68
  GitReflow::Sandbox.run "git config --global --add #{key} \"#{value}\"", loud: false, blocking: false
43
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,56 +84,69 @@ module GitReflow
84
84
  end
85
85
 
86
86
  def authenticate(options = {silent: false})
87
+ if !options[:user].to_s.empty?
88
+ self.class.user = options[:user]
89
+ elsif self.class.user.empty?
90
+ self.class.user = ask("Please enter your GitHub username: ")
91
+ end
92
+
87
93
  if connection and self.class.oauth_token.length > 0
88
- unless options[:silent]
89
- GitReflow.say "Your GitHub account was already setup with: "
90
- GitReflow.say "\tUser Name: #{self.class.user}"
91
- GitReflow.say "\tEndpoint: #{self.class.api_endpoint}"
92
- end
93
- else
94
94
  begin
95
- gh_user = options[:user] || ask("Please enter your GitHub username: ")
96
- gh_password = options[:password] || ask("Please enter your GitHub password (we do NOT store this): ") { |q| q.echo = false }
97
-
98
- @connection = ::Github.new do |config|
99
- config.basic_auth = "#{gh_user}:#{gh_password}"
100
- config.endpoint = GitServer::GitHub.api_endpoint
101
- config.site = GitServer::GitHub.site_url
102
- config.adapter = :net_http
95
+ connection.users.get
96
+ unless options[:silent]
97
+ GitReflow.say "Your GitHub account was already setup with: "
98
+ GitReflow.say "\tUser Name: #{self.class.user}"
99
+ GitReflow.say "\tEndpoint: #{self.class.api_endpoint}"
103
100
  end
101
+ return connection
102
+ rescue ::Github::Error::Unauthorized => e
103
+ GitReflow.logger.debug "[GitHub Error] Current oauth-token is invalid or expired..."
104
+ end
105
+ end
104
106
 
105
- @connection.connection_options = {headers: {"X-GitHub-OTP" => options[:two_factor_auth_code]}} if options[:two_factor_auth_code]
107
+ begin
108
+ gh_password = options[:password] || ask("Please enter your GitHub password (we do NOT store this): ") { |q| q.echo = false }
106
109
 
107
- previous_authorizations = @connection.oauth.all.select {|auth| auth.note == "git-reflow (#{run('hostname', loud: false).strip})" }
108
- if previous_authorizations.any?
109
- authorization = previous_authorizations.last
110
- GitReflow.say "You have previously setup git-reflow on this machine, but we can no longer find the stored token.", :error
111
- GitReflow.say "Please visit https://github.com/settings/tokens and delete the token for: git-reflow (#{run('hostname', loud: false).strip})", :notice
112
- raise "Setup could not be completed."
113
- else
114
- authorization = @connection.oauth.create scopes: ['repo'], note: "git-reflow (#{run('hostname', loud: false).strip})"
115
- end
110
+ @connection = ::Github.new do |config|
111
+ config.basic_auth = "#{self.class.user}:#{gh_password}"
112
+ config.endpoint = GitServer::GitHub.api_endpoint
113
+ config.site = GitServer::GitHub.site_url
114
+ config.adapter = :net_http
115
+ end
116
116
 
117
- self.class.oauth_token = authorization.token
117
+ @connection.connection_options = {headers: {"X-GitHub-OTP" => options[:two_factor_auth_code]}} if options[:two_factor_auth_code]
118
118
 
119
- rescue ::Github::Error::Unauthorized => e
120
- if e.inspect.to_s.include?('two-factor')
121
- begin
122
- # dummy request to trigger a 2FA SMS since a HTTP GET won't do it
123
- @connection.oauth.create scopes: ['repo'], note: "thank Github for not making this straightforward"
124
- rescue ::Github::Error::Unauthorized
125
- ensure
126
- two_factor_code = ask("Please enter your two-factor authentication code: ")
127
- self.authenticate options.merge({user: gh_user, password: gh_password, two_factor_auth_code: two_factor_code})
128
- end
129
- else
130
- GitReflow.say "Github Authentication Error: #{e.inspect}", :error
119
+ previous_authorizations = @connection.oauth.all.select {|auth| auth.note == "git-reflow (#{run('hostname', loud: false).strip})" }
120
+ if previous_authorizations.any?
121
+ authorization = previous_authorizations.last
122
+ GitReflow.say "You have previously setup git-reflow on this machine, but we can no longer find the stored token.", :error
123
+ GitReflow.say "Please visit https://github.com/settings/tokens and delete the token for: git-reflow (#{run('hostname', loud: false).strip})", :notice
124
+ raise "Setup could not be completed."
125
+ else
126
+ authorization = @connection.oauth.create scopes: ['repo'], note: "git-reflow (#{run('hostname', loud: false).strip})"
127
+ end
128
+
129
+ self.class.oauth_token = authorization.token
130
+
131
+ rescue ::Github::Error::Unauthorized => e
132
+ if e.inspect.to_s.include?('two-factor')
133
+ begin
134
+ # dummy request to trigger a 2FA SMS since a HTTP GET won't do it
135
+ @connection.oauth.create scopes: ['repo'], note: "thank Github for not making this straightforward"
136
+ rescue ::Github::Error::Unauthorized
137
+ ensure
138
+ two_factor_code = ask("Please enter your two-factor authentication code: ")
139
+ self.authenticate options.merge({user: self.class.user, password: gh_password, two_factor_auth_code: two_factor_code})
131
140
  end
132
- rescue StandardError => e
133
- raise "We were unable to authenticate with Github."
134
141
  else
135
- GitReflow.say "Your GitHub account was successfully setup!", :success
142
+ GitReflow.say "Github Authentication Error: #{e.inspect}", :error
143
+ raise "Setup could not be completed."
136
144
  end
145
+ rescue StandardError => e
146
+ raise "We were unable to authenticate with Github."
147
+ else
148
+ GitReflow.say "Your GitHub account was successfully setup!", :success
149
+
137
150
  end
138
151
 
139
152
  @connection
@@ -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.2"
2
+ VERSION = "0.9.6"
3
3
  end