git_helper 3.3.7 → 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: aa8dfc9e8dff01f688d1f18ac2db60d0f0d9c193ad9ad1a5d91ab54fa7e2cb47
4
- data.tar.gz: ed55743cbc0291c9058e8639c8b426d7201e5152d8f7f54c146df614a5cc154b
3
+ metadata.gz: 0f54fe4752a8c63fd35e668a15b6d0ed4c17e6646f1058de2d66056550305050
4
+ data.tar.gz: 4dd91a7a425990aceb3012064bb64ad55d2501f2975d5e75668e9540722c8121
5
5
  SHA512:
6
- metadata.gz: d412a23d9fb0daf6798fd0a364c536451361e3d195925e411b0ff2022ae0d2390f422f1fbcc2f83ce8830e38aa3371a76c10bea381cc565d9418c6b0a8ebdfda
7
- data.tar.gz: b7eab53f9e11d32d058f9d9b52a05ef7e87e08288ddd115c2011f937c4ccd6a6e1a5e83c2eab9cc85b6488a1f5d727d2945822c254212ac02284d0c8b1748bd6
6
+ metadata.gz: 8d618c4758a4f4f9387e58a2d5a41b85d052ae61afd8253ca2c3c718bba85791a03f85332a5ecb104ab49dee35e7a406ea3e25984301b0db4f18d8c51140c233
7
+ data.tar.gz: 19ee42210fc4a308e927ef5bbf40512c73cfd5513be8d68a3b3754510b78a76701768eec2a8fd4ad9f2d48cfe168a1f817f9ab465040349068c7e7980322fba8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_helper (3.3.7)
4
+ git_helper (3.4.0)
5
5
  gitlab (~> 4.16)
6
6
  gli (~> 2.13)
7
7
  highline_wrapper (~> 1.1)
@@ -49,7 +49,7 @@ GEM
49
49
  guard-compat (~> 1.1)
50
50
  rspec (>= 2.99.0, < 4.0)
51
51
  highline (2.0.3)
52
- highline_wrapper (1.1.0)
52
+ highline_wrapper (1.2.0)
53
53
  highline (~> 2.0)
54
54
  httparty (0.18.1)
55
55
  mime-types (~> 3.0)
data/README.md CHANGED
@@ -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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitHelper
4
- VERSION = '3.3.7'
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
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.7
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-05-19 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