git_helper 3.3.1 → 3.3.2
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 +2 -0
- data/Gemfile.lock +20 -0
- data/Guardfile +3 -1
- data/README.md +1 -1
- data/Rakefile +2 -0
- data/bin/git-helper +18 -13
- data/lib/git_helper.rb +5 -1
- data/lib/git_helper/change_remote.rb +11 -3
- data/lib/git_helper/checkout_default.rb +2 -0
- data/lib/git_helper/clean_branches.rb +2 -0
- data/lib/git_helper/code_request.rb +29 -16
- data/lib/git_helper/empty_commit.rb +2 -0
- data/lib/git_helper/forget_local_commits.rb +2 -0
- data/lib/git_helper/git_config_reader.rb +3 -5
- data/lib/git_helper/gitlab_client.rb +2 -0
- data/lib/git_helper/highline_cli.rb +3 -1
- data/lib/git_helper/local_code.rb +18 -8
- data/lib/git_helper/merge_request.rb +86 -66
- data/lib/git_helper/new_branch.rb +2 -0
- data/lib/git_helper/octokit_client.rb +2 -0
- data/lib/git_helper/pull_request.rb +94 -63
- data/lib/git_helper/setup.rb +37 -17
- data/lib/git_helper/version.rb +3 -1
- data/spec/git_helper/change_remote_spec.rb +17 -17
- data/spec/git_helper/checkout_default_spec.rb +2 -0
- data/spec/git_helper/clean_branches_spec.rb +2 -0
- data/spec/git_helper/code_request_spec.rb +2 -0
- data/spec/git_helper/empty_commit_spec.rb +2 -0
- data/spec/git_helper/forget_local_commits_spec.rb +2 -0
- data/spec/git_helper/git_config_reader_spec.rb +4 -2
- data/spec/git_helper/gitlab_client_spec.rb +2 -0
- data/spec/git_helper/highline_cli_spec.rb +7 -5
- data/spec/git_helper/local_code_spec.rb +2 -0
- data/spec/git_helper/merge_request_spec.rb +8 -7
- data/spec/git_helper/new_branch_spec.rb +2 -0
- data/spec/git_helper/octokit_client_spec.rb +2 -0
- data/spec/git_helper/pull_request_spec.rb +5 -3
- data/spec/git_helper/setup_spec.rb +12 -7
- data/spec/spec_helper.rb +3 -1
- metadata +17 -3
data/lib/git_helper/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'git_helper'
|
3
5
|
|
@@ -7,18 +9,17 @@ describe GitHelper::ChangeRemote do
|
|
7
9
|
let(:cli) { double(:highline_cli, ask_yes_no: true) }
|
8
10
|
let(:old_owner) { Faker::Internet.username }
|
9
11
|
let(:new_owner) { Faker::Internet.username }
|
10
|
-
let(:directory_entries) { [
|
12
|
+
let(:directory_entries) { ['.', '..', project, Faker::Lorem.word, Faker::Lorem.word] }
|
11
13
|
|
12
14
|
let(:local_code) do
|
13
15
|
double(:local_code,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
)
|
16
|
+
remotes: [remote1],
|
17
|
+
remote_name: Faker::Lorem.word,
|
18
|
+
ssh_remote?: true,
|
19
|
+
https_remote?: false,
|
20
|
+
remote_project: project,
|
21
|
+
remote_source: 'github.com',
|
22
|
+
change_remote: true)
|
22
23
|
end
|
23
24
|
|
24
25
|
subject { GitHelper::ChangeRemote.new(old_owner, new_owner) }
|
@@ -138,14 +139,13 @@ describe GitHelper::ChangeRemote do
|
|
138
139
|
context 'https remote' do
|
139
140
|
let(:local_code) do
|
140
141
|
double(:local_code,
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
)
|
142
|
+
remotes: [remote1],
|
143
|
+
remote_name: Faker::Lorem.word,
|
144
|
+
ssh_remote?: false,
|
145
|
+
https_remote?: false,
|
146
|
+
remote_project: project,
|
147
|
+
remote_source: 'github.com',
|
148
|
+
change_remote: true)
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'should ask if the remote is SSH' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'git_helper'
|
3
5
|
|
@@ -7,14 +9,14 @@ describe GitHelper::GitConfigReader do
|
|
7
9
|
let(:gitlab_user) { Faker::Internet.username }
|
8
10
|
let(:gitlab_token) { Faker::Internet.password(max_length: 10) }
|
9
11
|
|
10
|
-
let(:config_file)
|
12
|
+
let(:config_file) do
|
11
13
|
{
|
12
14
|
github_user: github_user,
|
13
15
|
github_token: github_token,
|
14
16
|
gitlab_user: gitlab_user,
|
15
17
|
gitlab_token: gitlab_token
|
16
18
|
}
|
17
|
-
|
19
|
+
end
|
18
20
|
|
19
21
|
subject { GitHelper::GitConfigReader.new }
|
20
22
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'git_helper'
|
3
5
|
|
@@ -12,7 +14,7 @@ describe GitHelper::HighlineCli do
|
|
12
14
|
end
|
13
15
|
|
14
16
|
describe '#ask' do
|
15
|
-
it 'should ask the highline client ask'do
|
17
|
+
it 'should ask the highline client ask' do
|
16
18
|
expect(highline_client).to receive(:ask)
|
17
19
|
subject.ask(Faker::Lorem.sentence)
|
18
20
|
end
|
@@ -23,7 +25,7 @@ describe GitHelper::HighlineCli do
|
|
23
25
|
end
|
24
26
|
|
25
27
|
describe '#ask_yes_no' do
|
26
|
-
it 'should ask the highline client ask'do
|
28
|
+
it 'should ask the highline client ask' do
|
27
29
|
expect(highline_client).to receive(:ask)
|
28
30
|
subject.ask_yes_no(Faker::Lorem.sentence)
|
29
31
|
end
|
@@ -39,13 +41,13 @@ describe GitHelper::HighlineCli do
|
|
39
41
|
end
|
40
42
|
|
41
43
|
describe '#ask_options' do
|
42
|
-
it 'should ask the highline client ask'do
|
44
|
+
it 'should ask the highline client ask' do
|
43
45
|
expect(highline_client).to receive(:ask)
|
44
|
-
subject.ask_options(Faker::Lorem.sentence, [
|
46
|
+
subject.ask_options(Faker::Lorem.sentence, %w[one two three])
|
45
47
|
end
|
46
48
|
|
47
49
|
it 'should return a string from the options' do
|
48
|
-
expect(subject.ask_options(Faker::Lorem.sentence, [
|
50
|
+
expect(subject.ask_options(Faker::Lorem.sentence, %w[one two three])).to be_a(String)
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'git_helper'
|
3
5
|
|
@@ -10,10 +12,9 @@ describe GitHelper::GitLabMergeRequest do
|
|
10
12
|
|
11
13
|
let(:merge_request) do
|
12
14
|
double(:merge_request,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
)
|
15
|
+
diff_refs: diff_refs,
|
16
|
+
web_url: Faker::Internet.url,
|
17
|
+
merge_commit_sha: Faker::Internet.password)
|
17
18
|
end
|
18
19
|
|
19
20
|
let(:options) do
|
@@ -38,7 +39,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
38
39
|
allow(subject).to receive(:remove_source_branch).and_return(false)
|
39
40
|
allow(subject).to receive(:new_mr_body).and_return('')
|
40
41
|
expect(gitlab_client_client).to receive(:create_merge_request).and_return(merge_request)
|
41
|
-
subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
|
42
|
+
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
42
43
|
end
|
43
44
|
|
44
45
|
it 'should call various other methods' do
|
@@ -46,7 +47,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
46
47
|
expect(subject).to receive(:remove_source_branch).and_return(false)
|
47
48
|
expect(subject).to receive(:new_mr_body).and_return('')
|
48
49
|
allow(gitlab_client_client).to receive(:create_merge_request).and_return(merge_request)
|
49
|
-
subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
|
50
|
+
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
50
51
|
end
|
51
52
|
|
52
53
|
it 'should catch the raised error if the creation does not work' do
|
@@ -54,7 +55,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
54
55
|
allow(subject).to receive(:remove_source_branch).and_return(false)
|
55
56
|
allow(subject).to receive(:new_mr_body).and_return('')
|
56
57
|
allow(gitlab_client_client).to receive(:create_merge_request).and_raise(StandardError)
|
57
|
-
expect(subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})).to eq(nil)
|
58
|
+
expect(subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })).to eq(nil)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'git_helper'
|
3
5
|
|
@@ -27,19 +29,19 @@ describe GitHelper::GitHubPullRequest do
|
|
27
29
|
it 'should call the octokit client to create' do
|
28
30
|
allow(subject).to receive(:new_pr_body).and_return('')
|
29
31
|
expect(octokit_client_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
|
30
|
-
subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
|
32
|
+
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
31
33
|
end
|
32
34
|
|
33
35
|
it 'should call various other methods' do
|
34
36
|
expect(subject).to receive(:new_pr_body).and_return('').at_least(:once)
|
35
37
|
allow(octokit_client_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
|
36
|
-
subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})
|
38
|
+
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
37
39
|
end
|
38
40
|
|
39
41
|
it 'should catch the raised error if the creation does not work' do
|
40
42
|
allow(subject).to receive(:new_pr_body).and_return('')
|
41
43
|
allow(octokit_client_client).to receive(:create_pull_request).and_raise(StandardError)
|
42
|
-
expect(subject.create({base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word})).to eq(nil)
|
44
|
+
expect(subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })).to eq(nil)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'git_helper'
|
3
5
|
|
@@ -11,7 +13,7 @@ describe GitHelper::Setup do
|
|
11
13
|
end
|
12
14
|
|
13
15
|
after do
|
14
|
-
GitHelper::Setup.instance_variable_set(
|
16
|
+
GitHelper::Setup.instance_variable_set('@highline', nil)
|
15
17
|
end
|
16
18
|
|
17
19
|
describe '#execute' do
|
@@ -33,6 +35,7 @@ describe GitHelper::Setup do
|
|
33
35
|
|
34
36
|
it 'should skip if the user opts not to continue' do
|
35
37
|
allow(File).to receive(:exists?).and_return(true)
|
38
|
+
allow(subject).to receive(:config_file_exists?).and_return(true)
|
36
39
|
allow(highline_cli).to receive(:ask_yes_no).and_return(false)
|
37
40
|
expect(subject).not_to receive(:create_or_update_config_file)
|
38
41
|
expect(subject).not_to receive(:create_or_update_plugin_files)
|
@@ -56,12 +59,12 @@ describe GitHelper::Setup do
|
|
56
59
|
|
57
60
|
describe '#config_file_exists?' do
|
58
61
|
it 'should return true if the file exists' do
|
59
|
-
allow(File).to receive(:
|
62
|
+
allow(File).to receive(:exist?).and_return(true)
|
60
63
|
expect(subject.send(:config_file_exists?)).to eq(true)
|
61
64
|
end
|
62
65
|
|
63
66
|
it 'should return false if the file does not exist' do
|
64
|
-
allow(File).to receive(:
|
67
|
+
allow(File).to receive(:exist?).and_return(false)
|
65
68
|
expect(subject.send(:config_file_exists?)).to eq(false)
|
66
69
|
end
|
67
70
|
end
|
@@ -114,10 +117,10 @@ describe GitHelper::Setup do
|
|
114
117
|
let(:plugins) do
|
115
118
|
[
|
116
119
|
{
|
117
|
-
|
120
|
+
name: 'plugin-file-one'
|
118
121
|
},
|
119
122
|
{
|
120
|
-
|
123
|
+
name: 'plugin-file-two'
|
121
124
|
}
|
122
125
|
]
|
123
126
|
end
|
@@ -139,7 +142,7 @@ describe GitHelper::Setup do
|
|
139
142
|
end
|
140
143
|
|
141
144
|
it 'should create the directory if it does not exist' do
|
142
|
-
allow(File).to receive(:
|
145
|
+
allow(File).to receive(:exist?).and_return(false)
|
143
146
|
allow(File).to receive(:open).and_return(nil)
|
144
147
|
expect(Dir).to receive(:mkdir)
|
145
148
|
allow(subject).to receive(:`).and_return(plugins_json)
|
@@ -148,7 +151,7 @@ describe GitHelper::Setup do
|
|
148
151
|
end
|
149
152
|
|
150
153
|
it 'should not create the directory if it already exists' do
|
151
|
-
allow(File).to receive(:
|
154
|
+
allow(File).to receive(:exist?).and_return(true)
|
152
155
|
allow(File).to receive(:open).and_return(nil)
|
153
156
|
expect(Dir).not_to receive(:mkdir)
|
154
157
|
allow(subject).to receive(:`).and_return(plugins_json)
|
@@ -157,6 +160,7 @@ describe GitHelper::Setup do
|
|
157
160
|
end
|
158
161
|
|
159
162
|
it 'should curl the GitHub API' do
|
163
|
+
allow(Dir).to receive(:mkdir).and_return(true)
|
160
164
|
allow(File).to receive(:exists?).and_return(true)
|
161
165
|
allow(File).to receive(:open).and_return(nil)
|
162
166
|
allow(subject).to receive(:`).and_return(plugins_json)
|
@@ -165,6 +169,7 @@ describe GitHelper::Setup do
|
|
165
169
|
end
|
166
170
|
|
167
171
|
it 'should go through the loop for each plugin' do
|
172
|
+
allow(Dir).to receive(:mkdir).and_return(true)
|
168
173
|
allow(File).to receive(:exists?).and_return(true)
|
169
174
|
allow(File).to receive(:open).and_return(nil)
|
170
175
|
expect(subject).to receive(:`).exactly(3).times
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faker'
|
2
4
|
|
3
5
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
@@ -33,7 +35,7 @@ RSpec.configure do |config|
|
|
33
35
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
36
|
end
|
35
37
|
|
36
|
-
config.filter_run :
|
38
|
+
config.filter_run focus: true
|
37
39
|
config.run_all_when_everything_filtered = true
|
38
40
|
|
39
41
|
# rspec-mocks config goes here. You can use an alternate test double
|
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.2
|
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-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '3.9'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: A set of GitHub and GitLab workflow scripts to provide a smoother development
|
140
154
|
process for your git projects.
|
141
155
|
email:
|
@@ -197,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
211
|
requirements:
|
198
212
|
- - ">="
|
199
213
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
214
|
+
version: '2.5'
|
201
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
216
|
requirements:
|
203
217
|
- - ">="
|