geet 0.23.0 → 0.24.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/.github/workflows/ci.yml +16 -2
- data/.gitignore +0 -1
- data/.ruby-version +1 -0
- data/Gemfile +3 -6
- data/bin/geet +2 -8
- data/geet.gemspec +4 -4
- data/lib/geet/commandline/configuration.rb +0 -1
- data/lib/geet/commandline/editor.rb +0 -2
- data/lib/geet/git/repository.rb +12 -21
- data/lib/geet/github/abstract_issue.rb +0 -6
- data/lib/geet/github/api_interface.rb +0 -1
- data/lib/geet/github/issue.rb +0 -3
- data/lib/geet/github/milestone.rb +0 -2
- data/lib/geet/github/pr.rb +0 -3
- data/lib/geet/github/user.rb +0 -3
- data/lib/geet/gitlab/pr.rb +3 -1
- data/lib/geet/helpers/json_helper.rb +4 -0
- data/lib/geet/helpers/os_helper.rb +21 -7
- data/lib/geet/helpers/services_workflow_helper.rb +12 -0
- data/lib/geet/helpers/summary_helper.rb +7 -0
- data/lib/geet/services/abstract_create_issue.rb +5 -5
- data/lib/geet/services/add_upstream_repo.rb +6 -0
- data/lib/geet/services/close_milestones.rb +0 -2
- data/lib/geet/services/comment_pr.rb +0 -3
- data/lib/geet/services/create_gist.rb +0 -4
- data/lib/geet/services/create_issue.rb +0 -4
- data/lib/geet/services/create_pr.rb +4 -6
- data/lib/geet/services/list_issues.rb +0 -3
- data/lib/geet/services/merge_pr.rb +0 -2
- data/lib/geet/services/open_pr.rb +0 -3
- data/lib/geet/services/open_repo.rb +0 -2
- data/lib/geet/shared/http_error.rb +8 -2
- data/lib/geet/shared/repo_permissions.rb +7 -2
- data/lib/geet/shared/selection.rb +3 -2
- data/lib/geet/utils/attributes_selection_manager.rb +15 -4
- data/lib/geet/utils/git_client.rb +4 -1
- data/lib/geet/utils/manual_list_selection.rb +39 -14
- data/lib/geet/utils/string_matching_selection.rb +5 -0
- data/lib/geet/version.rb +1 -1
- data/lib/geet.rb +11 -0
- data/sorbet/config +3 -1
- data/sorbet/rbi/gems/{rbs@3.9.5.rbi → rbs@4.0.0.dev.5.rbi} +2013 -680
- data/sorbet/rbi/gems/require-hooks@0.2.2.rbi +110 -0
- data/sorbet/rbi/gems/{spoom@1.6.3.rbi → spoom@1.7.11.rbi} +1139 -2246
- data/sorbet/rbi/gems/{tapioca@0.16.11.rbi → tapioca@0.17.10.rbi} +721 -835
- data/sorbet/rbi/gems/tsort@0.2.0.rbi +393 -0
- data/sorbet/rbi/gems/tty-prompt@0.23.1.rbi +3300 -2
- data/sorbet/rbi/gems/zeitwerk@2.7.4.rbi +1196 -0
- data/sorbet/rbi/shims/unresolved_gem_constants.rbi +4 -0
- data/spec/integration/create_pr_spec.rb +157 -147
- data/spec/integration/merge_pr_spec.rb +84 -85
- data/spec/spec_helper.rb +1 -1
- metadata +40 -6
|
@@ -12,105 +12,118 @@ describe Geet::Services::CreatePr do
|
|
|
12
12
|
|
|
13
13
|
context 'with github.com' do
|
|
14
14
|
context 'with labels, reviewers and milestones' do
|
|
15
|
-
it 'should create a PR'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
15
|
+
it 'should create a PR' do
|
|
16
|
+
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
|
17
|
+
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
|
18
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
|
19
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
|
20
|
+
allow(git_client).to receive(:remote_branch).and_return('mybranch')
|
|
21
|
+
expect(git_client).to receive(:fetch)
|
|
22
|
+
allow(git_client).to receive(:remote_branch_diff_commits).and_return([])
|
|
23
|
+
expect(git_client).to receive(:push)
|
|
24
|
+
|
|
25
|
+
expected_output = <<~STR
|
|
26
|
+
Finding labels...
|
|
27
|
+
Finding milestones...
|
|
28
|
+
Finding collaborators...
|
|
29
|
+
Pushing to remote branch...
|
|
30
|
+
Creating PR...
|
|
31
|
+
Adding labels bug, invalid...
|
|
32
|
+
Setting milestone 0.0.1...
|
|
33
|
+
Requesting review from donald-fr...
|
|
34
|
+
PR address: https://github.com/donaldduck/testrepo_f/pull/1
|
|
35
|
+
STR
|
|
36
|
+
|
|
37
|
+
actual_output = StringIO.new
|
|
38
|
+
|
|
39
|
+
actual_created_pr = VCR.use_cassette('github_com/create_pr', allow_unused_http_interactions: true) do
|
|
40
|
+
service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
|
41
|
+
service_instance.execute(
|
|
42
|
+
'Title', 'Description',
|
|
43
|
+
labels: 'bug,invalid', milestone: '0.0.1', reviewers: 'donald-fr'
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
expect(actual_output.string).to eql(expected_output)
|
|
48
|
+
|
|
49
|
+
expect(actual_created_pr.number).to eql(1)
|
|
50
|
+
expect(actual_created_pr.title).to eql('Title')
|
|
51
|
+
expect(actual_created_pr.link).to eql('https://github.com/donaldduck/testrepo_f/pull/1')
|
|
52
|
+
end
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
context 'on an upstream repository' do
|
|
53
|
-
it 'should create an upstream PR'
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
it 'should create an upstream PR' do
|
|
57
|
+
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
|
58
|
+
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
|
59
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
|
60
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
|
61
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
|
62
|
+
allow(git_client).to receive(:remote_defined?).with('upstream').and_return(true)
|
|
63
|
+
allow(git_client).to receive(:remote_branch).and_return('mybranch')
|
|
64
|
+
expect(git_client).to receive(:fetch)
|
|
65
|
+
allow(git_client).to receive(:remote_branch_diff_commits).and_return([])
|
|
66
|
+
expect(git_client).to receive(:push)
|
|
67
|
+
|
|
68
|
+
expected_output = <<~STR
|
|
69
|
+
Pushing to remote branch...
|
|
70
|
+
Creating PR...
|
|
71
|
+
PR address: https://github.com/donald-fr/testrepo_u/pull/8
|
|
72
|
+
STR
|
|
73
|
+
|
|
74
|
+
actual_output = StringIO.new
|
|
75
|
+
|
|
76
|
+
actual_created_pr = VCR.use_cassette('github_com/create_pr_upstream', allow_unused_http_interactions: true) do
|
|
77
|
+
service_instance = described_class.new(upstream_repository, out: actual_output, git_client: git_client)
|
|
78
|
+
service_instance.execute('Title', 'Description')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
expect(actual_output.string).to eql(expected_output)
|
|
82
|
+
|
|
83
|
+
expect(actual_created_pr.number).to eql(8)
|
|
84
|
+
expect(actual_created_pr.title).to eql('Title')
|
|
85
|
+
expect(actual_created_pr.link).to eql('https://github.com/donald-fr/testrepo_u/pull/8')
|
|
86
|
+
end
|
|
79
87
|
|
|
80
88
|
# It would be more consistent to have this UT outside of an upstream context, however this use
|
|
81
89
|
# case is actually a typical real-world one
|
|
82
90
|
#
|
|
83
91
|
context 'without write permissions' do
|
|
84
92
|
context 'without labels, reviewers and milestones' do
|
|
85
|
-
it 'should create a PR'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
it 'should create a PR' do
|
|
94
|
+
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
|
95
|
+
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
|
96
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
|
97
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
|
98
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
|
99
|
+
allow(git_client).to receive(:remote_defined?).with('upstream').and_return(true)
|
|
100
|
+
allow(git_client).to receive(:remote_branch).and_return('mybranch')
|
|
101
|
+
expect(git_client).to receive(:fetch)
|
|
102
|
+
allow(git_client).to receive(:remote_branch_diff_commits).and_return([])
|
|
103
|
+
expect(git_client).to receive(:push)
|
|
104
|
+
|
|
105
|
+
expected_output = <<~STR
|
|
106
|
+
Pushing to remote branch...
|
|
107
|
+
Creating PR...
|
|
108
|
+
PR address: https://github.com/donald-fr/testrepo_u/pull/9
|
|
109
|
+
STR
|
|
110
|
+
|
|
111
|
+
actual_output = StringIO.new
|
|
112
|
+
|
|
113
|
+
actual_created_pr = VCR.use_cassette('github_com/create_pr_upstream_without_write_permissions') do
|
|
114
|
+
service_instance = described_class.new(upstream_repository, out: actual_output, git_client: git_client)
|
|
115
|
+
service_instance.execute(
|
|
116
|
+
'Title', 'Description',
|
|
117
|
+
labels: '<ignored>'
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
expect(actual_output.string).to eql(expected_output)
|
|
122
|
+
|
|
123
|
+
expect(actual_created_pr.number).to eql(9)
|
|
124
|
+
expect(actual_created_pr.title).to eql('Title')
|
|
125
|
+
expect(actual_created_pr.link).to eql('https://github.com/donald-fr/testrepo_u/pull/9')
|
|
126
|
+
end
|
|
114
127
|
end
|
|
115
128
|
end
|
|
116
129
|
end
|
|
@@ -122,68 +135,65 @@ describe Geet::Services::CreatePr do
|
|
|
122
135
|
|
|
123
136
|
actual_output = StringIO.new
|
|
124
137
|
|
|
125
|
-
|
|
138
|
+
expect do
|
|
126
139
|
service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
|
127
|
-
service_instance.execute('Title', 'Description'
|
|
128
|
-
end
|
|
140
|
+
service_instance.execute('Title', 'Description')
|
|
141
|
+
end.to raise_error(RuntimeError, 'The working tree is not clean!')
|
|
129
142
|
|
|
130
|
-
expect(operation).to raise_error(RuntimeError, 'The working tree is not clean!')
|
|
131
143
|
expect(actual_output.string).to be_empty
|
|
132
144
|
end
|
|
133
145
|
|
|
134
|
-
it 'should push to the remote branch'
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
it "should create a remote branch, when there isn't one (is not tracked)"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
# expect(actual_output.string).to eql(expected_output)
|
|
186
|
-
# end
|
|
146
|
+
it 'should push to the remote branch' do
|
|
147
|
+
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
|
148
|
+
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
|
149
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
|
150
|
+
expect(git_client).to receive(:remote_branch).and_return('mybranch')
|
|
151
|
+
expect(git_client).to receive(:fetch)
|
|
152
|
+
allow(git_client).to receive(:remote_branch_diff_commits).and_return([])
|
|
153
|
+
expect(git_client).to receive(:push)
|
|
154
|
+
|
|
155
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
|
156
|
+
|
|
157
|
+
expected_output = <<~STR
|
|
158
|
+
Pushing to remote branch...
|
|
159
|
+
Creating PR...
|
|
160
|
+
PR address: https://github.com/donaldduck/testrepo_f/pull/2
|
|
161
|
+
STR
|
|
162
|
+
|
|
163
|
+
actual_output = StringIO.new
|
|
164
|
+
|
|
165
|
+
actual_created_pr = VCR.use_cassette('github_com/create_pr_in_auto_mode_with_push', allow_unused_http_interactions: true) do
|
|
166
|
+
service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
|
167
|
+
service_instance.execute('Title', 'Description')
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
expect(actual_output.string).to eql(expected_output)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should create a remote branch, when there isn't one (is not tracked)" do
|
|
174
|
+
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
|
175
|
+
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
|
176
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
|
177
|
+
expect(git_client).to receive(:remote_branch).and_return(nil)
|
|
178
|
+
expect(git_client).to receive(:push).with(remote_branch: 'mybranch')
|
|
179
|
+
|
|
180
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
|
181
|
+
|
|
182
|
+
expected_output = <<~STR
|
|
183
|
+
Creating remote branch "mybranch"...
|
|
184
|
+
Creating PR...
|
|
185
|
+
PR address: https://github.com/donaldduck/testrepo_f/pull/4
|
|
186
|
+
STR
|
|
187
|
+
|
|
188
|
+
actual_output = StringIO.new
|
|
189
|
+
|
|
190
|
+
actual_created_pr = VCR.use_cassette('github_com/create_pr_in_auto_mode_create_upstream', allow_unused_http_interactions: true) do
|
|
191
|
+
service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
|
192
|
+
service_instance.execute('Title', 'Description')
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
expect(actual_output.string).to eql(expected_output)
|
|
196
|
+
end
|
|
187
197
|
end
|
|
188
198
|
end # context 'with github.com'
|
|
189
199
|
end
|
|
@@ -18,103 +18,102 @@ describe Geet::Services::MergePr do
|
|
|
18
18
|
let(:main_branch) { 'main' }
|
|
19
19
|
|
|
20
20
|
before :each do
|
|
21
|
-
expect(git_client).to receive(:fetch)
|
|
21
|
+
expect(git_client).to receive(:fetch).twice
|
|
22
|
+
expect(git_client).to receive(:push)
|
|
23
|
+
expect(git_client).to receive(:cherry).with('HEAD', head: :main_branch).and_return([])
|
|
22
24
|
expect(git_client).to receive(:remote_branch_gone?).and_return(true)
|
|
23
25
|
expect(git_client).to receive(:checkout).with(main_branch)
|
|
24
26
|
expect(git_client).to receive(:rebase)
|
|
25
|
-
expect(git_client).to receive(:delete_branch).with('mybranch')
|
|
27
|
+
expect(git_client).to receive(:delete_branch).with('mybranch', force: false)
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
context 'with github.com' do
|
|
29
31
|
let(:repository_name) { 'testrepo_upstream' }
|
|
30
32
|
|
|
31
|
-
it 'should merge the PR for the current branch'
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# expect(actual_pr_number).to eql(expected_pr_number)
|
|
86
|
-
# end
|
|
33
|
+
it 'should merge the PR for the current branch' do
|
|
34
|
+
allow(git_client).to receive(:current_branch).and_return(branch)
|
|
35
|
+
allow(git_client).to receive(:main_branch).and_return(main_branch)
|
|
36
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
|
37
|
+
|
|
38
|
+
expected_pr_number = 1
|
|
39
|
+
expected_output = <<~STR
|
|
40
|
+
Finding PR with head (#{owner}:#{branch})...
|
|
41
|
+
Merging PR ##{expected_pr_number}...
|
|
42
|
+
Fetching repository...
|
|
43
|
+
Checking out #{main_branch}...
|
|
44
|
+
Rebasing...
|
|
45
|
+
Deleting local branch mybranch...
|
|
46
|
+
STR
|
|
47
|
+
|
|
48
|
+
actual_output = StringIO.new
|
|
49
|
+
|
|
50
|
+
service_result = VCR.use_cassette('github_com/merge_pr') do
|
|
51
|
+
described_class.new(repository, out: actual_output, git_client: git_client).execute
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
actual_pr_number = service_result.number
|
|
55
|
+
|
|
56
|
+
expect(actual_output.string).to eql(expected_output)
|
|
57
|
+
expect(actual_pr_number).to eql(expected_pr_number)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'should merge the PR for the current branch, with branch deletion' do
|
|
61
|
+
allow(git_client).to receive(:current_branch).and_return(branch)
|
|
62
|
+
allow(git_client).to receive(:main_branch).and_return(main_branch)
|
|
63
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
|
64
|
+
|
|
65
|
+
expected_pr_number = 2
|
|
66
|
+
expected_output = <<~STR
|
|
67
|
+
Finding PR with head (#{owner}:#{branch})...
|
|
68
|
+
Merging PR ##{expected_pr_number}...
|
|
69
|
+
Deleting remote branch #{branch}...
|
|
70
|
+
Fetching repository...
|
|
71
|
+
Checking out #{main_branch}...
|
|
72
|
+
Rebasing...
|
|
73
|
+
Deleting local branch mybranch...
|
|
74
|
+
STR
|
|
75
|
+
|
|
76
|
+
actual_output = StringIO.new
|
|
77
|
+
|
|
78
|
+
service_result = VCR.use_cassette('github_com/merge_pr_with_branch_deletion') do
|
|
79
|
+
described_class.new(repository, out: actual_output, git_client: git_client).execute(delete_branch: true)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
actual_pr_number = service_result.number
|
|
83
|
+
|
|
84
|
+
expect(actual_output.string).to eql(expected_output)
|
|
85
|
+
expect(actual_pr_number).to eql(expected_pr_number)
|
|
86
|
+
end
|
|
87
87
|
end # context 'with github.com'
|
|
88
88
|
|
|
89
89
|
context 'with gitlab.com' do
|
|
90
90
|
let(:repository_name) { 'testproject' }
|
|
91
91
|
|
|
92
|
-
it 'should merge the PR for the current branch'
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
# end
|
|
92
|
+
it 'should merge the PR for the current branch' do
|
|
93
|
+
allow(git_client).to receive(:current_branch).and_return(branch)
|
|
94
|
+
allow(git_client).to receive(:main_branch).and_return(main_branch)
|
|
95
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:#{owner}/#{repository_name}")
|
|
96
|
+
|
|
97
|
+
expected_pr_number = 4
|
|
98
|
+
expected_output = <<~STR
|
|
99
|
+
Finding PR with head (#{owner}:#{branch})...
|
|
100
|
+
Merging PR ##{expected_pr_number}...
|
|
101
|
+
Fetching repository...
|
|
102
|
+
Checking out #{main_branch}...
|
|
103
|
+
Rebasing...
|
|
104
|
+
Deleting local branch mybranch...
|
|
105
|
+
STR
|
|
106
|
+
|
|
107
|
+
actual_output = StringIO.new
|
|
108
|
+
|
|
109
|
+
service_result = VCR.use_cassette('gitlab_com/merge_pr') do
|
|
110
|
+
described_class.new(repository, out: actual_output, git_client: git_client).execute
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
actual_pr_number = service_result.number
|
|
114
|
+
|
|
115
|
+
expect(actual_output.string).to eql(expected_output)
|
|
116
|
+
expect(actual_pr_number).to eql(expected_pr_number)
|
|
117
|
+
end
|
|
119
118
|
end # context 'with gitlab.com'
|
|
120
119
|
end
|