git_helper 3.4.0 → 3.6.0
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 +45 -40
- data/Guardfile +1 -1
- data/LICENSE.md +29 -0
- data/README.md +19 -7
- data/lib/git_helper/github_client.rb +70 -0
- data/lib/git_helper/gitlab_client.rb +46 -2
- data/lib/git_helper/merge_request.rb +34 -30
- data/lib/git_helper/pull_request.rb +33 -46
- data/lib/git_helper/setup.rb +1 -1
- data/lib/git_helper/version.rb +1 -1
- data/lib/git_helper.rb +1 -2
- data/spec/git_helper/code_request_spec.rb +1 -1
- data/spec/git_helper/github_client_spec.rb +131 -0
- data/spec/git_helper/gitlab_client_spec.rb +120 -4
- data/spec/git_helper/merge_request_spec.rb +12 -13
- data/spec/git_helper/pull_request_spec.rb +18 -19
- metadata +9 -65
- data/LICENSE +0 -22
- data/lib/git_helper/octokit_client.rb +0 -13
- data/spec/git_helper/octokit_client_spec.rb +0 -28
@@ -250,7 +250,7 @@ describe GitHelper::CodeRequest do
|
|
250
250
|
end
|
251
251
|
|
252
252
|
describe '#local_code' do
|
253
|
-
it 'should call the
|
253
|
+
it 'should call the GitHub client' do
|
254
254
|
expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
255
255
|
subject.send(:local_code)
|
256
256
|
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'git_helper'
|
5
|
+
|
6
|
+
describe GitHelper::GitHubClient do
|
7
|
+
let(:git_config_reader) { double(:git_config_reader, github_token: :token) }
|
8
|
+
|
9
|
+
subject { GitHelper::GitHubClient.new }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(GitHelper::GitConfigReader).to receive(:new).and_return(git_config_reader)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#repository' do
|
16
|
+
it 'should call to run a query' do
|
17
|
+
expect(subject).to receive(:run)
|
18
|
+
subject.repository(Faker::Lorem.word)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return the run command's answer" do
|
22
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
23
|
+
expect(subject.repository(Faker::Lorem.word)).to eq(:command_complete)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#pull_request' do
|
28
|
+
it 'should call to run a query' do
|
29
|
+
expect(subject).to receive(:run)
|
30
|
+
subject.pull_request(Faker::Lorem.word, Faker::Number.number)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the run command's answer" do
|
34
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
35
|
+
expect(subject.pull_request(Faker::Lorem.word, Faker::Number.number)).to eq(:command_complete)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#create_pull_request' do
|
40
|
+
it 'should call to run a query' do
|
41
|
+
expect(subject).to receive(:run)
|
42
|
+
subject.create_pull_request(Faker::Lorem.word, {})
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should generate a string list of options' do
|
46
|
+
expect(subject).to receive(:format_options).with({})
|
47
|
+
subject.create_pull_request(Faker::Lorem.word, {})
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return the run command's answer" do
|
51
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
52
|
+
expect(subject.create_pull_request(Faker::Lorem.word, {})).to eq(:command_complete)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#merge_pull_request' do
|
57
|
+
it 'should call to run a query' do
|
58
|
+
expect(subject).to receive(:run)
|
59
|
+
subject.merge_pull_request(Faker::Lorem.word, Faker::Number.number, {})
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should generate a string list of options' do
|
63
|
+
expect(subject).to receive(:format_options).with({})
|
64
|
+
subject.merge_pull_request(Faker::Lorem.word, Faker::Number.number, {})
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return the run command's answer" do
|
68
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
69
|
+
expect(subject.merge_pull_request(Faker::Lorem.word, Faker::Number.number, {})).to eq(:command_complete)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#format_options' do
|
74
|
+
it 'will make a list of hash options into a JSON parsed chunk of key/value pairs as string' do
|
75
|
+
options = {
|
76
|
+
key1: 'value1',
|
77
|
+
key2: true,
|
78
|
+
key3: '',
|
79
|
+
key4: false,
|
80
|
+
key5: 'value5'
|
81
|
+
}
|
82
|
+
# rubocop:disable Style/StringLiterals
|
83
|
+
result = "{\"key1\":\"value1\",\"key2\":true,\"key4\":false,\"key5\":\"value5\"}"
|
84
|
+
# rubocop:enable Style/StringLiterals
|
85
|
+
expect(subject.send(:format_options, options)).to eq(result)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'will return an empty string if an empty hash is given' do
|
89
|
+
expect(subject.send(:format_options, {})).to eq('')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'will return an empty string if all values are empty strings' do
|
93
|
+
options = {
|
94
|
+
key1: '',
|
95
|
+
key2: '',
|
96
|
+
key3: ''
|
97
|
+
}
|
98
|
+
expect(subject.send(:format_options, options)).to eq('')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#run' do
|
103
|
+
it 'should call CURL' do
|
104
|
+
expect(subject).to receive(:`).and_return('{}')
|
105
|
+
subject.send(:run, Faker::Lorem.word, 'GET', "/projects/#{Faker::Lorem.word}")
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should use JSON to parse the response' do
|
109
|
+
expect(JSON).to receive(:parse).and_return({})
|
110
|
+
subject.send(:run, Faker::Lorem.word, 'GET', "/projects/#{Faker::Lorem.word}")
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should use OpenStruct to turn the hash into an object' do
|
114
|
+
expect(OpenStruct).to receive(:new).and_return(OpenStruct.new)
|
115
|
+
subject.send(:run, Faker::Lorem.word, 'GET', "/projects/#{Faker::Lorem.word}")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#github_token' do
|
120
|
+
it 'should return a token' do
|
121
|
+
expect(subject.send(:github_token)).to eq(:token)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#git_config_reader' do
|
126
|
+
it 'should make a new git config reader' do
|
127
|
+
expect(GitHelper::GitConfigReader).to receive(:new)
|
128
|
+
subject.send(:git_config_reader)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -12,10 +12,126 @@ describe GitHelper::GitLabClient do
|
|
12
12
|
allow(GitHelper::GitConfigReader).to receive(:new).and_return(git_config_reader)
|
13
13
|
end
|
14
14
|
|
15
|
-
describe '#
|
16
|
-
it 'should call
|
17
|
-
expect(
|
18
|
-
subject.
|
15
|
+
describe '#project' do
|
16
|
+
it 'should call to run a query' do
|
17
|
+
expect(subject).to receive(:run)
|
18
|
+
subject.project(Faker::Lorem.word)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return the run command's answer" do
|
22
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
23
|
+
expect(subject.project(Faker::Lorem.word)).to eq(:command_complete)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#merge_request' do
|
28
|
+
it 'should call to run a query' do
|
29
|
+
expect(subject).to receive(:run)
|
30
|
+
subject.merge_request(Faker::Lorem.word, Faker::Number.number)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the run command's answer" do
|
34
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
35
|
+
expect(subject.merge_request(Faker::Lorem.word, Faker::Number.number)).to eq(:command_complete)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#create_merge_request' do
|
40
|
+
it 'should call to run a query' do
|
41
|
+
expect(subject).to receive(:run)
|
42
|
+
subject.create_merge_request(Faker::Lorem.word, {})
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should generate a string list of options' do
|
46
|
+
expect(subject).to receive(:format_options).with({})
|
47
|
+
subject.create_merge_request(Faker::Lorem.word, {})
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return the run command's answer" do
|
51
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
52
|
+
expect(subject.create_merge_request(Faker::Lorem.word, {})).to eq(:command_complete)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#accept_merge_request' do
|
57
|
+
it 'should call to run a query' do
|
58
|
+
expect(subject).to receive(:run)
|
59
|
+
subject.accept_merge_request(Faker::Lorem.word, Faker::Number.number, {})
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should generate a string list of options' do
|
63
|
+
expect(subject).to receive(:format_options).with({})
|
64
|
+
subject.accept_merge_request(Faker::Lorem.word, Faker::Number.number, {})
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return the run command's answer" do
|
68
|
+
expect(subject).to receive(:run).and_return(:command_complete)
|
69
|
+
expect(subject.accept_merge_request(Faker::Lorem.word, Faker::Number.number, {})).to eq(:command_complete)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#format_options' do
|
74
|
+
it 'will make a list of hash options into a URL string' do
|
75
|
+
options = {
|
76
|
+
key1: 'value1',
|
77
|
+
key2: true,
|
78
|
+
key3: '',
|
79
|
+
key4: false,
|
80
|
+
key5: 'value5'
|
81
|
+
}
|
82
|
+
result = '?key1=value1&key2=true&key4=false&key5=value5'
|
83
|
+
expect(subject.send(:format_options, options)).to eq(result)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'will return an empty string if an empty hash is given' do
|
87
|
+
expect(subject.send(:format_options, {})).to eq('')
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'will return an empty string if all values are empty strings' do
|
91
|
+
options = {
|
92
|
+
key1: '',
|
93
|
+
key2: '',
|
94
|
+
key3: ''
|
95
|
+
}
|
96
|
+
expect(subject.send(:format_options, options)).to eq('')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#run' do
|
101
|
+
it 'should call CURL' do
|
102
|
+
expect(subject).to receive(:`).and_return('{}')
|
103
|
+
subject.send(:run, 'GET', "/projects/#{Faker::Lorem.word}")
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should use JSON to parse the response' do
|
107
|
+
expect(JSON).to receive(:parse).and_return({})
|
108
|
+
subject.send(:run, 'GET', "/projects/#{Faker::Lorem.word}")
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should use OpenStruct to turn the hash into an object' do
|
112
|
+
expect(OpenStruct).to receive(:new).and_return(OpenStruct.new)
|
113
|
+
subject.send(:run, 'GET', "/projects/#{Faker::Lorem.word}")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#url_encode' do
|
118
|
+
let(:group_name) { Faker::Lorem.word }
|
119
|
+
let(:project_name) { Faker::Lorem.word }
|
120
|
+
|
121
|
+
it 'should return the same string as passed in but with no spaces' do
|
122
|
+
expect(subject.send(:url_encode, "#{group_name}/#{project_name}")).to eq("#{group_name}%2F#{project_name}")
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should never include a space or a slash' do
|
126
|
+
resp = subject.send(:url_encode, "#{group_name} #{Faker::Lorem.word}/#{project_name}")
|
127
|
+
expect(resp).not_to include(' ')
|
128
|
+
expect(resp).not_to include('/')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#gitlab_token' do
|
133
|
+
it 'should return a token' do
|
134
|
+
expect(subject.send(:gitlab_token)).to eq(:token)
|
19
135
|
end
|
20
136
|
end
|
21
137
|
|
@@ -6,13 +6,12 @@ require 'git_helper'
|
|
6
6
|
describe GitHelper::GitLabMergeRequest do
|
7
7
|
let(:local_code) { double(:local_code, read_template: Faker::Lorem.word) }
|
8
8
|
let(:highline_wrapper) { double(:highline_wrapper) }
|
9
|
-
let(:
|
10
|
-
let(:gitlab_client) { double(:gitlab_client, client: gitlab_client_client) }
|
11
|
-
let(:diff_refs) { double(:diff_refs, base_sha: :base, head_sha: :head) }
|
9
|
+
let(:gitlab_client) { double(:gitlab_client) }
|
12
10
|
|
13
11
|
let(:merge_request) do
|
14
12
|
double(:merge_request,
|
15
|
-
|
13
|
+
message: Faker::Lorem.sentence,
|
14
|
+
diff_refs: { base_sha: Faker::Lorem.word, head_sha: Faker::Lorem.word },
|
16
15
|
web_url: Faker::Internet.url,
|
17
16
|
merge_commit_sha: Faker::Internet.password)
|
18
17
|
end
|
@@ -38,7 +37,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
38
37
|
allow(subject).to receive(:squash_merge_request).and_return(true)
|
39
38
|
allow(subject).to receive(:remove_source_branch).and_return(false)
|
40
39
|
allow(subject).to receive(:new_mr_body).and_return('')
|
41
|
-
expect(
|
40
|
+
expect(gitlab_client).to receive(:create_merge_request).and_return(merge_request)
|
42
41
|
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
43
42
|
end
|
44
43
|
|
@@ -46,7 +45,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
46
45
|
expect(subject).to receive(:squash_merge_request).and_return(true)
|
47
46
|
expect(subject).to receive(:remove_source_branch).and_return(false)
|
48
47
|
expect(subject).to receive(:new_mr_body).and_return('')
|
49
|
-
allow(
|
48
|
+
allow(gitlab_client).to receive(:create_merge_request).and_return(merge_request)
|
50
49
|
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
51
50
|
end
|
52
51
|
|
@@ -54,7 +53,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
54
53
|
allow(subject).to receive(:squash_merge_request).and_return(true)
|
55
54
|
allow(subject).to receive(:remove_source_branch).and_return(false)
|
56
55
|
allow(subject).to receive(:new_mr_body).and_return('')
|
57
|
-
allow(
|
56
|
+
allow(gitlab_client).to receive(:create_merge_request).and_raise(StandardError)
|
58
57
|
expect(subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })).to eq(nil)
|
59
58
|
end
|
60
59
|
end
|
@@ -63,28 +62,28 @@ describe GitHelper::GitLabMergeRequest do
|
|
63
62
|
it 'should call the gitlab client to merge' do
|
64
63
|
allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
|
65
64
|
allow(subject).to receive(:mr_id).and_return(Faker::Number.number)
|
66
|
-
expect(
|
65
|
+
expect(gitlab_client).to receive(:accept_merge_request).and_return(merge_request)
|
67
66
|
subject.merge
|
68
67
|
end
|
69
68
|
|
70
69
|
it 'should call various other methods' do
|
71
70
|
expect(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title')).at_least(:once)
|
72
71
|
expect(subject).to receive(:mr_id).and_return(Faker::Number.number).at_least(:once)
|
73
|
-
allow(
|
72
|
+
allow(gitlab_client).to receive(:accept_merge_request).and_return(merge_request)
|
74
73
|
subject.merge
|
75
74
|
end
|
76
75
|
|
77
76
|
it 'should catch the raised error if the merge does not work' do
|
78
77
|
allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
|
79
78
|
allow(subject).to receive(:mr_id).and_return(Faker::Number.number)
|
80
|
-
allow(
|
79
|
+
allow(gitlab_client).to receive(:accept_merge_request).and_raise(StandardError)
|
81
80
|
expect(subject.merge).to eq(nil)
|
82
81
|
end
|
83
82
|
|
84
83
|
it 'should try to merge multiple times if the first merge errors' do
|
85
84
|
allow(subject).to receive(:existing_mr).and_return(double(should_remove_source_branch: true, squash: false, title: 'title'))
|
86
85
|
allow(subject).to receive(:mr_id).and_return(Faker::Number.number)
|
87
|
-
expect(
|
86
|
+
expect(gitlab_client).to receive(:accept_merge_request).and_return(double(merge_commit_sha: nil, merge_error: Faker::Lorem.word, message: Faker::Lorem.sentence)).exactly(2).times
|
88
87
|
expect(subject.merge).to eq(nil)
|
89
88
|
end
|
90
89
|
end
|
@@ -257,7 +256,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
257
256
|
|
258
257
|
describe '#existing_project' do
|
259
258
|
it 'should call the gitlab client' do
|
260
|
-
expect(
|
259
|
+
expect(gitlab_client).to receive(:project).and_return(:project)
|
261
260
|
subject.send(:existing_project)
|
262
261
|
end
|
263
262
|
end
|
@@ -265,7 +264,7 @@ describe GitHelper::GitLabMergeRequest do
|
|
265
264
|
describe '#existing_mr' do
|
266
265
|
it 'should call the gitlab client' do
|
267
266
|
allow(highline_wrapper).to receive(:ask).and_return(Faker::Number.number)
|
268
|
-
expect(
|
267
|
+
expect(gitlab_client).to receive(:merge_request).and_return(:merge_request)
|
269
268
|
subject.send(:existing_mr)
|
270
269
|
end
|
271
270
|
end
|
@@ -6,8 +6,7 @@ require 'git_helper'
|
|
6
6
|
describe GitHelper::GitHubPullRequest do
|
7
7
|
let(:local_code) { double(:local_code, read_template: Faker::Lorem.word) }
|
8
8
|
let(:highline_wrapper) { double(:highline_wrapper) }
|
9
|
-
let(:
|
10
|
-
let(:octokit_client) { double(:octokit_client, client: octokit_client_client) }
|
9
|
+
let(:github_client) { double(:github_client) }
|
11
10
|
|
12
11
|
let(:options) do
|
13
12
|
{
|
@@ -21,36 +20,36 @@ describe GitHelper::GitHubPullRequest do
|
|
21
20
|
subject { GitHelper::GitHubPullRequest.new(options) }
|
22
21
|
|
23
22
|
before do
|
24
|
-
allow(GitHelper::
|
23
|
+
allow(GitHelper::GitHubClient).to receive(:new).and_return(github_client)
|
25
24
|
allow(subject).to receive(:puts)
|
26
25
|
end
|
27
26
|
|
28
27
|
describe '#create' do
|
29
|
-
it 'should call the
|
28
|
+
it 'should call the GitHub client to create' do
|
30
29
|
allow(subject).to receive(:new_pr_body).and_return('')
|
31
|
-
expect(
|
30
|
+
expect(github_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
|
32
31
|
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
33
32
|
end
|
34
33
|
|
35
34
|
it 'should call various other methods' do
|
36
35
|
expect(subject).to receive(:new_pr_body).and_return('').at_least(:once)
|
37
|
-
allow(
|
36
|
+
allow(github_client).to receive(:create_pull_request).and_return(double(html_url: Faker::Internet.url))
|
38
37
|
subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })
|
39
38
|
end
|
40
39
|
|
41
40
|
it 'should catch the raised error if the creation does not work' do
|
42
41
|
allow(subject).to receive(:new_pr_body).and_return('')
|
43
|
-
allow(
|
42
|
+
allow(github_client).to receive(:create_pull_request).and_raise(StandardError)
|
44
43
|
expect(subject.create({ base_branch: Faker::Lorem.word, new_title: Faker::Lorem.word })).to eq(nil)
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
47
|
describe '#merge' do
|
49
|
-
it 'should call the
|
48
|
+
it 'should call the GitHub client to merge' do
|
50
49
|
allow(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word))
|
51
50
|
allow(subject).to receive(:merge_method).and_return('rebase')
|
52
51
|
allow(subject).to receive(:pr_id).and_return(Faker::Number.number)
|
53
|
-
expect(
|
52
|
+
expect(github_client).to receive(:merge_pull_request).and_return(double(sha: Faker::Internet.password))
|
54
53
|
subject.merge
|
55
54
|
end
|
56
55
|
|
@@ -58,7 +57,7 @@ describe GitHelper::GitHubPullRequest do
|
|
58
57
|
expect(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word)).at_least(:once)
|
59
58
|
expect(subject).to receive(:merge_method).and_return('rebase').at_least(:once)
|
60
59
|
expect(subject).to receive(:pr_id).and_return(Faker::Number.number).at_least(:once)
|
61
|
-
allow(
|
60
|
+
allow(github_client).to receive(:merge_pull_request).and_return(double(sha: Faker::Internet.password))
|
62
61
|
subject.merge
|
63
62
|
end
|
64
63
|
|
@@ -66,7 +65,7 @@ describe GitHelper::GitHubPullRequest do
|
|
66
65
|
allow(subject).to receive(:existing_pr).and_return(double(title: Faker::Lorem.word))
|
67
66
|
allow(subject).to receive(:merge_method).and_return('rebase')
|
68
67
|
allow(subject).to receive(:pr_id).and_return(Faker::Number.number)
|
69
|
-
allow(
|
68
|
+
allow(github_client).to receive(:merge_pull_request).and_raise(StandardError)
|
70
69
|
expect(subject.merge).to eq(nil)
|
71
70
|
end
|
72
71
|
end
|
@@ -233,24 +232,24 @@ describe GitHelper::GitHubPullRequest do
|
|
233
232
|
end
|
234
233
|
|
235
234
|
describe '#existing_project' do
|
236
|
-
it 'should call the
|
237
|
-
expect(
|
235
|
+
it 'should call the GitHub client' do
|
236
|
+
expect(github_client).to receive(:repository).and_return(:repository)
|
238
237
|
subject.send(:existing_project)
|
239
238
|
end
|
240
239
|
end
|
241
240
|
|
242
241
|
describe '#existing_pr' do
|
243
|
-
it 'should call the
|
242
|
+
it 'should call the GitHub client' do
|
244
243
|
allow(highline_wrapper).to receive(:ask).and_return(Faker::Number.number)
|
245
|
-
expect(
|
244
|
+
expect(github_client).to receive(:pull_request).and_return(:pull_request)
|
246
245
|
subject.send(:existing_pr)
|
247
246
|
end
|
248
247
|
end
|
249
248
|
|
250
|
-
describe '#
|
251
|
-
it 'should call the
|
252
|
-
expect(GitHelper::
|
253
|
-
subject.send(:
|
249
|
+
describe '#github_client' do
|
250
|
+
it 'should call the GitHub client' do
|
251
|
+
expect(GitHelper::GitHubClient).to receive(:new).and_return(github_client)
|
252
|
+
subject.send(:github_client)
|
254
253
|
end
|
255
254
|
end
|
256
255
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.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-
|
11
|
+
date: 2021-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: gitlab
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4.16'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '4.16'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: gli
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,34 +38,6 @@ dependencies:
|
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '1.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: octokit
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '4.18'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
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'
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
name: bundler
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,20 +94,6 @@ dependencies:
|
|
136
94
|
- - "~>"
|
137
95
|
- !ruby/object:Gem::Version
|
138
96
|
version: '0.13'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rake
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '13.0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '13.0'
|
153
97
|
- !ruby/object:Gem::Dependency
|
154
98
|
name: rspec
|
155
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,7 +133,7 @@ files:
|
|
189
133
|
- Gemfile
|
190
134
|
- Gemfile.lock
|
191
135
|
- Guardfile
|
192
|
-
- LICENSE
|
136
|
+
- LICENSE.md
|
193
137
|
- README.md
|
194
138
|
- Rakefile
|
195
139
|
- bin/git-helper
|
@@ -201,11 +145,11 @@ files:
|
|
201
145
|
- lib/git_helper/empty_commit.rb
|
202
146
|
- lib/git_helper/forget_local_commits.rb
|
203
147
|
- lib/git_helper/git_config_reader.rb
|
148
|
+
- lib/git_helper/github_client.rb
|
204
149
|
- lib/git_helper/gitlab_client.rb
|
205
150
|
- lib/git_helper/local_code.rb
|
206
151
|
- lib/git_helper/merge_request.rb
|
207
152
|
- lib/git_helper/new_branch.rb
|
208
|
-
- lib/git_helper/octokit_client.rb
|
209
153
|
- lib/git_helper/pull_request.rb
|
210
154
|
- lib/git_helper/setup.rb
|
211
155
|
- lib/git_helper/version.rb
|
@@ -217,17 +161,17 @@ files:
|
|
217
161
|
- spec/git_helper/empty_commit_spec.rb
|
218
162
|
- spec/git_helper/forget_local_commits_spec.rb
|
219
163
|
- spec/git_helper/git_config_reader_spec.rb
|
164
|
+
- spec/git_helper/github_client_spec.rb
|
220
165
|
- spec/git_helper/gitlab_client_spec.rb
|
221
166
|
- spec/git_helper/local_code_spec.rb
|
222
167
|
- spec/git_helper/merge_request_spec.rb
|
223
168
|
- spec/git_helper/new_branch_spec.rb
|
224
|
-
- spec/git_helper/octokit_client_spec.rb
|
225
169
|
- spec/git_helper/pull_request_spec.rb
|
226
170
|
- spec/git_helper/setup_spec.rb
|
227
171
|
- spec/spec_helper.rb
|
228
172
|
homepage: https://github.com/emmahsax/git_helper
|
229
173
|
licenses:
|
230
|
-
-
|
174
|
+
- BSD-3-Clause
|
231
175
|
metadata: {}
|
232
176
|
post_install_message:
|
233
177
|
rdoc_options: []
|
@@ -244,10 +188,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
188
|
- !ruby/object:Gem::Version
|
245
189
|
version: '0'
|
246
190
|
requirements: []
|
247
|
-
rubygems_version: 3.2.
|
191
|
+
rubygems_version: 3.2.22
|
248
192
|
signing_key:
|
249
193
|
specification_version: 4
|
250
|
-
summary: A set of GitHub and GitLab workflow scripts
|
194
|
+
summary: A set of GitHub and GitLab workflow scripts
|
251
195
|
test_files:
|
252
196
|
- spec/spec_helper.rb
|
253
197
|
- spec/git_helper/change_remote_spec.rb
|
@@ -257,10 +201,10 @@ test_files:
|
|
257
201
|
- spec/git_helper/empty_commit_spec.rb
|
258
202
|
- spec/git_helper/forget_local_commits_spec.rb
|
259
203
|
- spec/git_helper/git_config_reader_spec.rb
|
204
|
+
- spec/git_helper/github_client_spec.rb
|
260
205
|
- spec/git_helper/gitlab_client_spec.rb
|
261
206
|
- spec/git_helper/local_code_spec.rb
|
262
207
|
- spec/git_helper/merge_request_spec.rb
|
263
208
|
- spec/git_helper/new_branch_spec.rb
|
264
|
-
- spec/git_helper/octokit_client_spec.rb
|
265
209
|
- spec/git_helper/pull_request_spec.rb
|
266
210
|
- spec/git_helper/setup_spec.rb
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright 2020 Emma Sax
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GitHelper
|
4
|
-
class OctokitClient
|
5
|
-
def client
|
6
|
-
Octokit::Client.new(access_token: git_config_reader.github_token)
|
7
|
-
end
|
8
|
-
|
9
|
-
private def git_config_reader
|
10
|
-
@git_config_reader ||= GitHelper::GitConfigReader.new
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|