git_helper 3.3.2 → 3.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +29 -20
- data/README.md +4 -4
- data/lib/git_helper.rb +1 -1
- data/lib/git_helper/change_remote.rb +6 -5
- data/lib/git_helper/code_request.rb +10 -9
- data/lib/git_helper/merge_request.rb +7 -7
- data/lib/git_helper/new_branch.rb +1 -1
- data/lib/git_helper/pull_request.rb +6 -6
- data/lib/git_helper/setup.rb +19 -19
- data/lib/git_helper/version.rb +1 -1
- data/spec/git_helper/change_remote_spec.rb +7 -7
- data/spec/git_helper/code_request_spec.rb +28 -28
- data/spec/git_helper/merge_request_spec.rb +16 -16
- data/spec/git_helper/new_branch_spec.rb +8 -8
- data/spec/git_helper/pull_request_spec.rb +15 -15
- data/spec/git_helper/setup_spec.rb +22 -19
- data/spec/spec_helper.rb +1 -0
- metadata +38 -13
- data/lib/git_helper/highline_cli.rb +0 -35
- data/spec/git_helper/highline_cli_spec.rb +0 -53
@@ -4,11 +4,10 @@ require 'spec_helper'
|
|
4
4
|
require 'git_helper'
|
5
5
|
|
6
6
|
describe GitHelper::Setup do
|
7
|
-
let(:
|
8
|
-
let(:highline_cli) { double(:highline_cli, ask: response, ask_yes_no: true) }
|
7
|
+
let(:highline_wrapper) { double(:highline_wrapper, ask: Faker::Lorem.word, ask_yes_no: true) }
|
9
8
|
|
10
9
|
before do
|
11
|
-
allow(
|
10
|
+
allow(HighlineWrapper).to receive(:new).and_return(highline_wrapper)
|
12
11
|
allow(subject).to receive(:puts)
|
13
12
|
end
|
14
13
|
|
@@ -17,9 +16,19 @@ describe GitHelper::Setup do
|
|
17
16
|
end
|
18
17
|
|
19
18
|
describe '#execute' do
|
20
|
-
it '
|
19
|
+
it 'only asks the user one question if the config file does not exist' do
|
20
|
+
allow(subject).to receive(:config_file_exists?).and_return(false)
|
21
21
|
allow(File).to receive(:exists?).and_return(true)
|
22
|
-
expect(
|
22
|
+
expect(highline_wrapper).to receive(:ask_yes_no).and_return(true).exactly(:once)
|
23
|
+
allow(subject).to receive(:create_or_update_config_file).and_return(true)
|
24
|
+
allow(subject).to receive(:create_or_update_plugin_files)
|
25
|
+
subject.execute
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should ask two questions if the config file exists' do
|
29
|
+
allow(subject).to receive(:config_file_exists?).and_return(true)
|
30
|
+
allow(File).to receive(:exists?).and_return(true)
|
31
|
+
expect(highline_wrapper).to receive(:ask_yes_no).and_return(true).at_least(:twice)
|
23
32
|
allow(subject).to receive(:create_or_update_config_file).and_return(true)
|
24
33
|
allow(subject).to receive(:create_or_update_plugin_files)
|
25
34
|
subject.execute
|
@@ -27,7 +36,7 @@ describe GitHelper::Setup do
|
|
27
36
|
|
28
37
|
it 'should call to create or update the config file' do
|
29
38
|
allow(File).to receive(:exists?).and_return(true)
|
30
|
-
allow(
|
39
|
+
allow(highline_wrapper).to receive(:ask_yes_no).and_return(true)
|
31
40
|
expect(subject).to receive(:create_or_update_config_file).and_return(true)
|
32
41
|
allow(subject).to receive(:create_or_update_plugin_files)
|
33
42
|
subject.execute
|
@@ -36,7 +45,7 @@ describe GitHelper::Setup do
|
|
36
45
|
it 'should skip if the user opts not to continue' do
|
37
46
|
allow(File).to receive(:exists?).and_return(true)
|
38
47
|
allow(subject).to receive(:config_file_exists?).and_return(true)
|
39
|
-
allow(
|
48
|
+
allow(highline_wrapper).to receive(:ask_yes_no).and_return(false)
|
40
49
|
expect(subject).not_to receive(:create_or_update_config_file)
|
41
50
|
expect(subject).not_to receive(:create_or_update_plugin_files)
|
42
51
|
subject.execute
|
@@ -71,43 +80,37 @@ describe GitHelper::Setup do
|
|
71
80
|
|
72
81
|
describe '#ask_question' do
|
73
82
|
it 'should use highline to ask a question' do
|
74
|
-
expect(
|
75
|
-
subject.send(:ask_question, Faker::Lorem.sentence)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should recurse if the highline client gets an empty string' do
|
79
|
-
allow(highline_cli).to receive(:ask).and_return('', Faker::Lorem.word)
|
80
|
-
expect(subject).to receive(:ask_question).at_least(:twice).and_call_original
|
83
|
+
expect(highline_wrapper).to receive(:ask).and_return(Faker::Lorem.word)
|
81
84
|
subject.send(:ask_question, Faker::Lorem.sentence)
|
82
85
|
end
|
83
86
|
|
84
87
|
it 'should return the answer if it is given' do
|
85
88
|
answer = Faker::Lorem.sentence
|
86
|
-
allow(
|
89
|
+
allow(highline_wrapper).to receive(:ask).and_return(answer)
|
87
90
|
expect(subject.send(:ask_question, Faker::Lorem.sentence)).to be(answer)
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
91
94
|
describe '#generate_file_contents' do
|
92
95
|
it 'should ask two yes/no questions' do
|
93
|
-
expect(
|
96
|
+
expect(highline_wrapper).to receive(:ask_yes_no).exactly(2).times.and_return(false)
|
94
97
|
subject.send(:generate_file_contents)
|
95
98
|
end
|
96
99
|
|
97
100
|
it 'should ask two additional questions for each time the user says yes' do
|
98
|
-
allow(
|
101
|
+
allow(highline_wrapper).to receive(:ask_yes_no).exactly(2).times.and_return(true, false)
|
99
102
|
expect(subject).to receive(:ask_question).exactly(2).times.and_return(Faker::Lorem.word)
|
100
103
|
subject.send(:generate_file_contents)
|
101
104
|
end
|
102
105
|
|
103
106
|
it 'should ask four additional questions for each time the user says yes' do
|
104
|
-
allow(
|
107
|
+
allow(highline_wrapper).to receive(:ask_yes_no).exactly(2).times.and_return(true)
|
105
108
|
expect(subject).to receive(:ask_question).exactly(4).times.and_return(Faker::Lorem.word)
|
106
109
|
subject.send(:generate_file_contents)
|
107
110
|
end
|
108
111
|
|
109
112
|
it 'should return a string no matter what' do
|
110
|
-
allow(
|
113
|
+
allow(highline_wrapper).to receive(:ask_yes_no).exactly(2).times.and_return(true)
|
111
114
|
allow(subject).to receive(:ask_question).exactly(4).times.and_return(Faker::Lorem.word)
|
112
115
|
expect(subject.send(:generate_file_contents)).to be_a(String)
|
113
116
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 3.3.7
|
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-
|
11
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: highline_wrapper
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
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: '
|
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
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '4.3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.13'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.13'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: rake
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,16 +168,16 @@ dependencies:
|
|
140
168
|
name: rubocop
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
142
170
|
requirements:
|
143
|
-
- - "
|
171
|
+
- - "~>"
|
144
172
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
173
|
+
version: '1.10'
|
146
174
|
type: :development
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
|
-
- - "
|
178
|
+
- - "~>"
|
151
179
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
180
|
+
version: '1.10'
|
153
181
|
description: A set of GitHub and GitLab workflow scripts to provide a smoother development
|
154
182
|
process for your git projects.
|
155
183
|
email:
|
@@ -174,7 +202,6 @@ files:
|
|
174
202
|
- lib/git_helper/forget_local_commits.rb
|
175
203
|
- lib/git_helper/git_config_reader.rb
|
176
204
|
- lib/git_helper/gitlab_client.rb
|
177
|
-
- lib/git_helper/highline_cli.rb
|
178
205
|
- lib/git_helper/local_code.rb
|
179
206
|
- lib/git_helper/merge_request.rb
|
180
207
|
- lib/git_helper/new_branch.rb
|
@@ -191,7 +218,6 @@ files:
|
|
191
218
|
- spec/git_helper/forget_local_commits_spec.rb
|
192
219
|
- spec/git_helper/git_config_reader_spec.rb
|
193
220
|
- spec/git_helper/gitlab_client_spec.rb
|
194
|
-
- spec/git_helper/highline_cli_spec.rb
|
195
221
|
- spec/git_helper/local_code_spec.rb
|
196
222
|
- spec/git_helper/merge_request_spec.rb
|
197
223
|
- spec/git_helper/new_branch_spec.rb
|
@@ -218,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
244
|
- !ruby/object:Gem::Version
|
219
245
|
version: '0'
|
220
246
|
requirements: []
|
221
|
-
rubygems_version: 3.2.
|
247
|
+
rubygems_version: 3.2.15
|
222
248
|
signing_key:
|
223
249
|
specification_version: 4
|
224
250
|
summary: A set of GitHub and GitLab workflow scripts.
|
@@ -232,7 +258,6 @@ test_files:
|
|
232
258
|
- spec/git_helper/forget_local_commits_spec.rb
|
233
259
|
- spec/git_helper/git_config_reader_spec.rb
|
234
260
|
- spec/git_helper/gitlab_client_spec.rb
|
235
|
-
- spec/git_helper/highline_cli_spec.rb
|
236
261
|
- spec/git_helper/local_code_spec.rb
|
237
262
|
- spec/git_helper/merge_request_spec.rb
|
238
263
|
- spec/git_helper/new_branch_spec.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GitHelper
|
4
|
-
class HighlineCli
|
5
|
-
def ask(prompt)
|
6
|
-
highline_client.ask(prompt) do |conf|
|
7
|
-
conf.readline = true
|
8
|
-
end.to_s
|
9
|
-
end
|
10
|
-
|
11
|
-
def ask_yes_no(prompt)
|
12
|
-
answer = highline_client.ask(prompt) do |conf|
|
13
|
-
conf.readline = true
|
14
|
-
end.to_s
|
15
|
-
|
16
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
17
|
-
end
|
18
|
-
|
19
|
-
def ask_options(prompt, choices)
|
20
|
-
choices_as_string_options = ''.dup
|
21
|
-
choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
|
22
|
-
compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"
|
23
|
-
|
24
|
-
index = highline_client.ask(compiled_prompt) do |conf|
|
25
|
-
conf.readline = true
|
26
|
-
end.to_i - 1
|
27
|
-
|
28
|
-
choices[index]
|
29
|
-
end
|
30
|
-
|
31
|
-
private def highline_client
|
32
|
-
@highline_client ||= HighLine.new
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'git_helper'
|
5
|
-
|
6
|
-
describe GitHelper::HighlineCli do
|
7
|
-
let(:response) { double(:response, readline: true, to_i: 3) }
|
8
|
-
let(:highline_client) { double(:highline_cli, ask: response) }
|
9
|
-
|
10
|
-
subject { GitHelper::HighlineCli.new }
|
11
|
-
|
12
|
-
before do
|
13
|
-
allow(HighLine).to receive(:new).and_return(highline_client)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#ask' do
|
17
|
-
it 'should ask the highline client ask' do
|
18
|
-
expect(highline_client).to receive(:ask)
|
19
|
-
subject.ask(Faker::Lorem.sentence)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should return a string' do
|
23
|
-
expect(subject.ask(Faker::Lorem.sentence)).to be_a(String)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#ask_yes_no' do
|
28
|
-
it 'should ask the highline client ask' do
|
29
|
-
expect(highline_client).to receive(:ask)
|
30
|
-
subject.ask_yes_no(Faker::Lorem.sentence)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should return a boolean' do
|
34
|
-
expect(subject.ask_yes_no(Faker::Lorem.sentence)).to be_falsey
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should return true if we say yes' do
|
38
|
-
allow(response).to receive(:to_s).and_return('y')
|
39
|
-
expect(subject.ask_yes_no(Faker::Lorem.sentence)).to be_truthy
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#ask_options' do
|
44
|
-
it 'should ask the highline client ask' do
|
45
|
-
expect(highline_client).to receive(:ask)
|
46
|
-
subject.ask_options(Faker::Lorem.sentence, %w[one two three])
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should return a string from the options' do
|
50
|
-
expect(subject.ask_options(Faker::Lorem.sentence, %w[one two three])).to be_a(String)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|