git_helper 3.3.3 → 3.4.0

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
  SHA256:
3
- metadata.gz: e7e2fb7b1199964740a0d73091815fb81469b492a3de04adc16aea30ba794e79
4
- data.tar.gz: 80abd21099775a4829c1e72accb74f7f91ae6e9f5e536cfd0468879065de06ff
3
+ metadata.gz: 0f54fe4752a8c63fd35e668a15b6d0ed4c17e6646f1058de2d66056550305050
4
+ data.tar.gz: 4dd91a7a425990aceb3012064bb64ad55d2501f2975d5e75668e9540722c8121
5
5
  SHA512:
6
- metadata.gz: 5fdabeaa00c72c8f58e00bce3f054949ad1061dbbb132661d06caf788ca827b486d44c20d57213582c2eb7b9c8db28ac88636b5e4562366010c33cc6056c526c
7
- data.tar.gz: '08eee4e6e95562f500c93df42f72a713b43ece4d39c96013d5313612f13bf33dc4b7dcd5ca6de243d3bba360af8d8bc183d6c5f2a8600d9692de2afa3bf7c675'
6
+ metadata.gz: 8d618c4758a4f4f9387e58a2d5a41b85d052ae61afd8253ca2c3c718bba85791a03f85332a5ecb104ab49dee35e7a406ea3e25984301b0db4f18d8c51140c233
7
+ data.tar.gz: 19ee42210fc4a308e927ef5bbf40512c73cfd5513be8d68a3b3754510b78a76701768eec2a8fd4ad9f2d48cfe168a1f817f9ab465040349068c7e7980322fba8
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_helper (3.3.2)
4
+ git_helper (3.4.0)
5
5
  gitlab (~> 4.16)
6
6
  gli (~> 2.13)
7
- highline_wrapper (~> 0.1.0)
7
+ highline_wrapper (~> 1.1)
8
8
  octokit (~> 4.18)
9
+ psych (< 4)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -16,14 +17,18 @@ GEM
16
17
  coderay (1.1.3)
17
18
  concurrent-ruby (1.1.8)
18
19
  diff-lcs (1.4.4)
19
- faker (2.15.1)
20
+ faker (2.17.0)
20
21
  i18n (>= 1.6, < 2)
21
- faraday (1.3.0)
22
+ faraday (1.4.1)
23
+ faraday-excon (~> 1.1)
22
24
  faraday-net_http (~> 1.0)
25
+ faraday-net_http_persistent (~> 1.1)
23
26
  multipart-post (>= 1.2, < 3)
24
- ruby2_keywords
27
+ ruby2_keywords (>= 0.0.4)
28
+ faraday-excon (1.1.0)
25
29
  faraday-net_http (1.0.1)
26
- ffi (1.14.2)
30
+ faraday-net_http_persistent (1.1.0)
31
+ ffi (1.15.0)
27
32
  formatador (0.2.5)
28
33
  gitlab (4.17.0)
29
34
  httparty (~> 0.18)
@@ -44,14 +49,14 @@ GEM
44
49
  guard-compat (~> 1.1)
45
50
  rspec (>= 2.99.0, < 4.0)
46
51
  highline (2.0.3)
47
- highline_wrapper (0.1.0)
52
+ highline_wrapper (1.2.0)
48
53
  highline (~> 2.0)
49
54
  httparty (0.18.1)
50
55
  mime-types (~> 3.0)
51
56
  multi_xml (>= 0.5.2)
52
- i18n (1.8.8)
57
+ i18n (1.8.10)
53
58
  concurrent-ruby (~> 1.0)
54
- listen (3.4.1)
59
+ listen (3.5.1)
55
60
  rb-fsevent (~> 0.10, >= 0.10.3)
56
61
  rb-inotify (~> 0.9, >= 0.9.10)
57
62
  lumberjack (1.2.8)
@@ -65,15 +70,16 @@ GEM
65
70
  notiffany (0.1.3)
66
71
  nenv (~> 0.1)
67
72
  shellany (~> 0.0)
68
- octokit (4.20.0)
73
+ octokit (4.21.0)
69
74
  faraday (>= 0.9)
70
75
  sawyer (~> 0.8.0, >= 0.5.3)
71
76
  parallel (1.20.1)
72
- parser (3.0.0.0)
77
+ parser (3.0.1.1)
73
78
  ast (~> 2.4.1)
74
- pry (0.14.0)
79
+ pry (0.14.1)
75
80
  coderay (~> 1.1)
76
81
  method_source (~> 1.0)
82
+ psych (3.3.2)
77
83
  public_suffix (4.0.6)
78
84
  rainbow (3.0.0)
79
85
  rake (13.0.3)
@@ -81,7 +87,7 @@ GEM
81
87
  rb-inotify (0.10.1)
82
88
  ffi (~> 1.0)
83
89
  regexp_parser (2.1.1)
84
- rexml (3.2.4)
90
+ rexml (3.2.5)
85
91
  rspec (3.10.0)
86
92
  rspec-core (~> 3.10.0)
87
93
  rspec-expectations (~> 3.10.0)
@@ -95,17 +101,17 @@ GEM
95
101
  diff-lcs (>= 1.2.0, < 2.0)
96
102
  rspec-support (~> 3.10.0)
97
103
  rspec-support (3.10.2)
98
- rubocop (1.10.0)
104
+ rubocop (1.14.0)
99
105
  parallel (~> 1.10)
100
106
  parser (>= 3.0.0.0)
101
107
  rainbow (>= 2.2.2, < 4.0)
102
108
  regexp_parser (>= 1.8, < 3.0)
103
109
  rexml
104
- rubocop-ast (>= 1.2.0, < 2.0)
110
+ rubocop-ast (>= 1.5.0, < 2.0)
105
111
  ruby-progressbar (~> 1.7)
106
112
  unicode-display_width (>= 1.4.0, < 3.0)
107
- rubocop-ast (1.4.1)
108
- parser (>= 2.7.1.5)
113
+ rubocop-ast (1.5.0)
114
+ parser (>= 3.0.1.1)
109
115
  ruby-progressbar (1.11.0)
110
116
  ruby2_keywords (0.0.4)
111
117
  sawyer (0.8.2)
@@ -131,4 +137,4 @@ DEPENDENCIES
131
137
  rubocop (~> 1.10)
132
138
 
133
139
  BUNDLED WITH
134
- 2.2.9
140
+ 2.2.17
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # git_helper [![Main](https://github.com/emmahsax/git_helper/actions/workflows/main.yml/badge.svg)](https://github.com/emmahsax/git_helper/actions/workflows/main.yml)
1
+ # Git Helper [![Main](https://github.com/emmahsax/git_helper/actions/workflows/main.yml/badge.svg)](https://github.com/emmahsax/git_helper/actions/workflows/main.yml)
2
2
 
3
3
  ## Gem Usage
4
4
 
@@ -115,7 +115,7 @@ git-helper clean-branches
115
115
 
116
116
  ### `code-request`
117
117
 
118
- This command can be used to handily make new GitHub/GitLab pull/merge requests from the command line. The command uses either the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) or [`Gitlab` client](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `~/.git_helper/config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Gem Usage](#gem-usage).
118
+ This command can be used to handily make new GitHub/GitLab pull/merge requests from the command-line. The command uses either the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) or [`Gitlab` client](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `~/.git_helper/config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Gem Usage](#gem-usage).
119
119
 
120
120
  After setup is complete, you can call the command like this:
121
121
 
@@ -127,7 +127,7 @@ The command will provide an autogenerated code request title based on your branc
127
127
 
128
128
  The command will also ask you if the default branch of the repository is the proper base branch to use. You can say 'yes' or 'no'. If you respond 'no', then you can give the command your chosen base base.
129
129
 
130
- If your project uses GitLab, the command will potentially ask you if you'd like to delete the source branch upon merge. If the project defaults to deleting the source branch, then the script will use that selection, and the value can be changed for a specific MR either over the API or in the browser. If the project just provides source branch deletion as on option, then it'll ask the user. It also will probably ask you if you'd like to squash the MR upon merge. If the project requires or prevents squashing, then whatever answer you give will be _*ignored*_. This is unfortunate, but is here due to limited API functionality.
130
+ If your project uses GitLab, the command will potentially ask you if you'd like to delete the source branch upon merge. If the project defaults to deleting the source branch, then the script will use that selection, and the value can be changed for a specific MR either over the API or in the browser. If the project just provides source branch deletion as on option, then it'll ask the user. If the project has allowed squashing, but doesn't default it, then the code will ask the user whether to squash the merge request. If the project has set merge requests to require squashing, prevent squashing, or sets the project to default to squashing, then the code will skip a squash question. If default squashing is set, then the code will set the merge request to squash, and the user can change that over the API or in the browser.
131
131
 
132
132
  Lastly, it'll ask about code request templates. For GitHub, it'll ask the user to apply any pull request templates found at `.github/pull_request_template.md`, `./pull_request_template.md`, or `.github/PULL_REQUEST_TEMPLATE/*.md`. Applying any template is optional, and a user can make an empty pull request if they desire. For GitLab, it'll ask the user to apply any merge request templates found at any `.gitlab/merge_request_template.md`, `./merge_request_template.md`, or `.gitlab/merge_request_templates/*.md`. Applying any template is optional, and from the command's standpoint, a user can make an empty merge request if they desire (although GitLab may still add a merge request template if the project itself requires one). When searching for templates, the code ignores cases, so the file could be named with all capital letters or all lowercase letters.
133
133
 
@@ -149,7 +149,7 @@ git-helper forget-local-commits
149
149
 
150
150
  ### `merge-code-request`
151
151
 
152
- This command can be used to merge pull/merge requests from the command line. The command uses either the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) or [`Gitlab` client](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `~/.git_helper/config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Gem Usage](#gem-usage).
152
+ This command can be used to merge pull/merge requests from the command-line. The command uses either the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) or [`Gitlab` client](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `~/.git_helper/config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Gem Usage](#gem-usage).
153
153
 
154
154
  After setup is complete, you can call the proper command like this:
155
155
 
@@ -166,7 +166,7 @@ For GitLab, the command will use whatever squash/source branch deletion/etc sett
166
166
 
167
167
  ### `new-branch`
168
168
 
169
- This command is useful for making new branches in a repository on the command line. To run the command, run:
169
+ This command is useful for making new branches in a repository on the command-line. To run the command, run:
170
170
 
171
171
  ```bash
172
172
  git-helper new-branch
@@ -25,7 +25,8 @@ module GitHelper
25
25
  Dir.chdir(current_dir)
26
26
 
27
27
  if File.exist?('.git') && highline.ask_yes_no(
28
- "Found git directory: #{current_dir}. Do you wish to proceed in updating #{current_dir}'s remote URLs? (y/n)"
28
+ "Found git directory: #{current_dir}. Do you wish to proceed in updating #{current_dir}'s remote URLs? (y/n)",
29
+ { required: true }
29
30
  )
30
31
  process_git_repository
31
32
  end
@@ -41,7 +42,7 @@ module GitHelper
41
42
  puts " Found remote is not pointing to #{old_owner}."
42
43
  end
43
44
  end
44
- puts "\n"
45
+ puts
45
46
  end
46
47
 
47
48
  # rubocop:disable Metrics/AbcSize
@@ -31,7 +31,8 @@ module GitHelper
31
31
  private def ask_for_clarification
32
32
  resp = highline.ask(
33
33
  'Found git remotes for both GitHub and GitLab. Would you like to proceed ' \
34
- 'with GitLab or GitHub? (github/gitlab)'
34
+ 'with GitLab or GitHub? (github/gitlab)',
35
+ { required: true }
35
36
  ).downcase
36
37
 
37
38
  if resp.include?('hub')
@@ -75,7 +76,7 @@ module GitHelper
75
76
  if highline.ask_yes_no("Is '#{default_branch}' the correct base branch for your new code request? (y/n)")
76
77
  default_branch
77
78
  else
78
- highline.ask('Base branch?')
79
+ highline.ask('Base branch?', { required: true })
79
80
  end
80
81
  end
81
82
 
@@ -94,7 +95,7 @@ module GitHelper
94
95
  )
95
96
  autogenerated_title
96
97
  else
97
- highline.ask('Title?')
98
+ highline.ask('Title?', { required: true })
98
99
  end
99
100
  end
100
101
 
@@ -125,7 +125,16 @@ module GitHelper
125
125
  end
126
126
 
127
127
  private def squash_merge_request
128
- @squash_merge_request ||= highline.ask_yes_no('Squash merge request? (y/n)')
128
+ return @squash_merge_request if @squash_merge_request
129
+
130
+ case existing_project.squash_option
131
+ when 'always', 'default_on'
132
+ @squash_merge_request = true
133
+ when 'never'
134
+ @squash_merge_request = false
135
+ else # 'default_off' or anything else
136
+ @squash_merge_request = highline.ask_yes_no('Squash merge request? (y/n)')
137
+ end
129
138
  end
130
139
 
131
140
  private def remove_source_branch
@@ -3,7 +3,7 @@
3
3
  module GitHelper
4
4
  class NewBranch
5
5
  def execute(new_branch_name = nil)
6
- branch_name = new_branch_name || HighlineWrapper.new.ask('New branch name?')
6
+ branch_name = new_branch_name || HighlineWrapper.new.ask('New branch name?', { required: true })
7
7
  puts "Attempting to create a new branch: #{branch_name}"
8
8
  GitHelper::LocalCode.new.new_branch(branch_name)
9
9
  end
@@ -7,23 +7,26 @@ module GitHelper
7
7
  execute_plugins
8
8
  end
9
9
 
10
+ # rubocop:disable Style/ConditionalAssignment
10
11
  private def execute_config_file
11
12
  if config_file_exists?
12
13
  answer = highline.ask_yes_no(
13
- "It looks like the #{config_file} file already exists. Do you wish to replace it? (y/n)"
14
+ "It looks like the #{config_file} file already exists. Do you wish to replace it? (y/n)",
15
+ { required: true }
14
16
  )
15
- puts
16
17
  else
17
18
  answer = true
18
19
  end
19
20
 
20
21
  create_or_update_config_file if answer
21
22
  end
23
+ # rubocop:enable Style/ConditionalAssignment
22
24
 
23
25
  private def execute_plugins
24
26
  answer = highline.ask_yes_no(
25
27
  'Do you wish to set up the Git Helper plugins? (y/n) (This process will ' \
26
- 'attempt to use your GitHub personal access token to authenticate)'
28
+ 'attempt to use your GitHub personal access token to authenticate)',
29
+ { required: true }
27
30
  )
28
31
 
29
32
  return unless answer
@@ -36,7 +39,7 @@ module GitHelper
36
39
 
37
40
  private def create_or_update_config_file
38
41
  contents = generate_file_contents
39
- puts "\nCreating or updating your #{config_file} file..."
42
+ puts "Creating or updating your #{config_file} file..."
40
43
  File.open(config_file, 'w') { |file| file.puts contents }
41
44
  puts "\nDone!\n\n"
42
45
  end
@@ -49,19 +52,23 @@ module GitHelper
49
52
  private def generate_file_contents
50
53
  file_contents = ''.dup
51
54
 
52
- if highline.ask_yes_no('Do you wish to set up GitHub credentials? (y/n)')
55
+ if highline.ask_yes_no('Do you wish to set up GitHub credentials? (y/n)', { required: true })
53
56
  file_contents << ":github_user: #{ask_question('GitHub username?')}\n"
54
57
  file_contents << ':github_token: ' \
55
- "#{ask_question('GitHub personal access token? (Navigate to https://github.com/settings/tokens ' \
56
- 'to create a new personal access token)')}\n"
58
+ "#{ask_question(
59
+ 'GitHub personal access token? (Navigate to https://github.com/settings/tokens ' \
60
+ 'to create a new personal access token)',
61
+ secret: true
62
+ )}\n"
57
63
  end
58
64
 
59
- if highline.ask_yes_no("\nDo you wish to set up GitLab credentials? (y/n)")
65
+ if highline.ask_yes_no('Do you wish to set up GitLab credentials? (y/n)', { required: true })
60
66
  file_contents << ":gitlab_user: #{ask_question('GitLab username?')}\n"
61
67
  file_contents << ':gitlab_token: ' \
62
68
  "#{ask_question(
63
69
  'GitLab personal access token? (Navigate to https://gitlab.com/-/profile/personal_access_tokens' \
64
- ' to create a new personal access token)'
70
+ ' to create a new personal access token)',
71
+ secret: true
65
72
  )}\n"
66
73
  end
67
74
 
@@ -69,15 +76,8 @@ module GitHelper
69
76
  end
70
77
  # rubocop:enable Metrics/MethodLength
71
78
 
72
- private def ask_question(prompt)
73
- answer = highline.ask("\n#{prompt}")
74
-
75
- if answer.empty?
76
- puts "\nThis question is required."
77
- ask_question(prompt)
78
- else
79
- answer
80
- end
79
+ private def ask_question(prompt, secret: false)
80
+ highline.ask(prompt, { required: true, secret: secret })
81
81
  end
82
82
 
83
83
  # rubocop:disable Metrics/MethodLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitHelper
4
- VERSION = '3.3.3'
4
+ VERSION = '3.4.0'
5
5
  end
@@ -183,12 +183,39 @@ describe GitHelper::GitLabMergeRequest do
183
183
  end
184
184
 
185
185
  describe '#squash_merge_request' do
186
- it 'should ask the CLI for the code request ID' do
186
+ let(:existing_project) { double(squash_option: 'default_off') }
187
+
188
+ it 'should return true if the squash is set to always on the project' do
189
+ allow(subject).to receive(:existing_project).and_return(existing_project)
190
+ allow(existing_project).to receive(:squash_option).and_return('always')
191
+ expect(highline_wrapper).not_to receive(:ask_yes_no)
192
+ expect(subject.send(:squash_merge_request)).to eq(true)
193
+ end
194
+
195
+ it 'should return true if the squash is set to default_on on the project' do
196
+ allow(subject).to receive(:existing_project).and_return(existing_project)
197
+ allow(existing_project).to receive(:squash_option).and_return('default_on')
198
+ expect(highline_wrapper).not_to receive(:ask_yes_no)
199
+ expect(subject.send(:squash_merge_request)).to eq(true)
200
+ end
201
+
202
+ it 'should return false if the squash is set to never on the project' do
203
+ allow(subject).to receive(:existing_project).and_return(existing_project)
204
+ allow(existing_project).to receive(:squash_option).and_return('never')
205
+ expect(highline_wrapper).not_to receive(:ask_yes_no)
206
+ expect(subject.send(:squash_merge_request)).to eq(false)
207
+ end
208
+
209
+ it 'should ask the user for their response to the squash question' do
210
+ allow(subject).to receive(:existing_project).and_return(existing_project)
211
+ allow(existing_project).to receive(:squash_option).and_return(nil)
187
212
  expect(highline_wrapper).to receive(:ask_yes_no).and_return(true)
188
213
  subject.send(:squash_merge_request)
189
214
  end
190
215
 
191
216
  it 'should be a boolean' do
217
+ allow(subject).to receive(:existing_project).and_return(existing_project)
218
+ allow(existing_project).to receive(:squash_option).and_return(nil)
192
219
  expect(highline_wrapper).to receive(:ask_yes_no).and_return(false)
193
220
  expect([true, false]).to include(subject.send(:squash_merge_request))
194
221
  end
@@ -84,12 +84,6 @@ describe GitHelper::Setup do
84
84
  subject.send(:ask_question, Faker::Lorem.sentence)
85
85
  end
86
86
 
87
- it 'should recurse if the highline client gets an empty string' do
88
- allow(highline_wrapper).to receive(:ask).and_return('', Faker::Lorem.word)
89
- expect(subject).to receive(:ask_question).at_least(:twice).and_call_original
90
- subject.send(:ask_question, Faker::Lorem.sentence)
91
- end
92
-
93
87
  it 'should return the answer if it is given' do
94
88
  answer = Faker::Lorem.sentence
95
89
  allow(highline_wrapper).to receive(:ask).and_return(answer)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.0
47
+ version: '1.1'
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
- version: 0.1.0
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: octokit
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.18'
69
+ - !ruby/object:Gem::Dependency
70
+ name: psych
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '4'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -230,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
244
  - !ruby/object:Gem::Version
231
245
  version: '0'
232
246
  requirements: []
233
- rubygems_version: 3.2.3
247
+ rubygems_version: 3.2.15
234
248
  signing_key:
235
249
  specification_version: 4
236
250
  summary: A set of GitHub and GitLab workflow scripts.