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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +16 -2
  3. data/.gitignore +0 -1
  4. data/.ruby-version +1 -0
  5. data/Gemfile +3 -6
  6. data/bin/geet +2 -8
  7. data/geet.gemspec +4 -4
  8. data/lib/geet/commandline/configuration.rb +0 -1
  9. data/lib/geet/commandline/editor.rb +0 -2
  10. data/lib/geet/git/repository.rb +12 -21
  11. data/lib/geet/github/abstract_issue.rb +0 -6
  12. data/lib/geet/github/api_interface.rb +0 -1
  13. data/lib/geet/github/issue.rb +0 -3
  14. data/lib/geet/github/milestone.rb +0 -2
  15. data/lib/geet/github/pr.rb +0 -3
  16. data/lib/geet/github/user.rb +0 -3
  17. data/lib/geet/gitlab/pr.rb +3 -1
  18. data/lib/geet/helpers/json_helper.rb +4 -0
  19. data/lib/geet/helpers/os_helper.rb +21 -7
  20. data/lib/geet/helpers/services_workflow_helper.rb +12 -0
  21. data/lib/geet/helpers/summary_helper.rb +7 -0
  22. data/lib/geet/services/abstract_create_issue.rb +5 -5
  23. data/lib/geet/services/add_upstream_repo.rb +6 -0
  24. data/lib/geet/services/close_milestones.rb +0 -2
  25. data/lib/geet/services/comment_pr.rb +0 -3
  26. data/lib/geet/services/create_gist.rb +0 -4
  27. data/lib/geet/services/create_issue.rb +0 -4
  28. data/lib/geet/services/create_pr.rb +4 -6
  29. data/lib/geet/services/list_issues.rb +0 -3
  30. data/lib/geet/services/merge_pr.rb +0 -2
  31. data/lib/geet/services/open_pr.rb +0 -3
  32. data/lib/geet/services/open_repo.rb +0 -2
  33. data/lib/geet/shared/http_error.rb +8 -2
  34. data/lib/geet/shared/repo_permissions.rb +7 -2
  35. data/lib/geet/shared/selection.rb +3 -2
  36. data/lib/geet/utils/attributes_selection_manager.rb +15 -4
  37. data/lib/geet/utils/git_client.rb +4 -1
  38. data/lib/geet/utils/manual_list_selection.rb +39 -14
  39. data/lib/geet/utils/string_matching_selection.rb +5 -0
  40. data/lib/geet/version.rb +1 -1
  41. data/lib/geet.rb +11 -0
  42. data/sorbet/config +3 -1
  43. data/sorbet/rbi/gems/{rbs@3.9.5.rbi → rbs@4.0.0.dev.5.rbi} +2013 -680
  44. data/sorbet/rbi/gems/require-hooks@0.2.2.rbi +110 -0
  45. data/sorbet/rbi/gems/{spoom@1.6.3.rbi → spoom@1.7.11.rbi} +1139 -2246
  46. data/sorbet/rbi/gems/{tapioca@0.16.11.rbi → tapioca@0.17.10.rbi} +721 -835
  47. data/sorbet/rbi/gems/tsort@0.2.0.rbi +393 -0
  48. data/sorbet/rbi/gems/tty-prompt@0.23.1.rbi +3300 -2
  49. data/sorbet/rbi/gems/zeitwerk@2.7.4.rbi +1196 -0
  50. data/sorbet/rbi/shims/unresolved_gem_constants.rbi +4 -0
  51. data/spec/integration/create_pr_spec.rb +157 -147
  52. data/spec/integration/merge_pr_spec.rb +84 -85
  53. data/spec/spec_helper.rb +1 -1
  54. metadata +40 -6
@@ -0,0 +1,4 @@
1
+ # For unclear reasons, these constants are not resolved.
2
+
3
+ module Geet::Commandline::Configuration::SimpleScripting::Argv; end
4
+ module Geet::Utils::ManualListSelection::TTY::Prompt; end
@@ -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
- # do
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
- #
21
- # expected_output = <<~STR
22
- # Finding labels...
23
- # Finding milestones...
24
- # Finding collaborators...
25
- # Creating PR...
26
- # Assigning authenticated user...
27
- # Adding labels bug, invalid...
28
- # Setting milestone 0.0.1...
29
- # Requesting review from donald-fr...
30
- # PR address: https://github.com/donaldduck/testrepo_f/pull/1
31
- # STR
32
- #
33
- # actual_output = StringIO.new
34
- #
35
- # actual_created_pr = VCR.use_cassette('github_com/create_pr') do
36
- # service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
37
- # service_instance.execute(
38
- # 'Title', 'Description',
39
- # labels: 'bug,invalid', milestone: '0.0.1', reviewers: 'donald-fr',
40
- # output: actual_output
41
- # )
42
- # end
43
- #
44
- # expect(actual_output.string).to eql(expected_output)
45
- #
46
- # expect(actual_created_pr.number).to eql(1)
47
- # expect(actual_created_pr.title).to eql('Title')
48
- # expect(actual_created_pr.link).to eql('https://github.com/donaldduck/testrepo_f/pull/1')
49
- # end
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
- # do
55
- # allow(git_client).to receive(:current_branch).and_return('mybranch')
56
- # allow(git_client).to receive(:main_branch).and_return('master')
57
- # allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
58
- # allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
59
- #
60
- # expected_output = <<~STR
61
- # Creating PR...
62
- # Assigning authenticated user...
63
- # PR address: https://github.com/donald-fr/testrepo_u/pull/8
64
- # STR
65
- #
66
- # actual_output = StringIO.new
67
- #
68
- # actual_created_pr = VCR.use_cassette('github_com/create_pr_upstream') do
69
- # service_instance = described_class.new(upstream_repository, out: actual_output, git_client: git_client)
70
- # service_instance.execute('Title', 'Description', output: actual_output)
71
- # end
72
- #
73
- # expect(actual_output.string).to eql(expected_output)
74
- #
75
- # expect(actual_created_pr.number).to eql(8)
76
- # expect(actual_created_pr.title).to eql('Title')
77
- # expect(actual_created_pr.link).to eql('https://github.com/donald-fr/testrepo_u/pull/8')
78
- # end
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
- # do
87
- # allow(git_client).to receive(:current_branch).and_return('mybranch')
88
- # allow(git_client).to receive(:main_branch).and_return('master')
89
- # allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
90
- # allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
91
- #
92
- # expected_output = <<~STR
93
- # Creating PR...
94
- # PR address: https://github.com/donald-fr/testrepo_u/pull/9
95
- # STR
96
- #
97
- # actual_output = StringIO.new
98
- #
99
- # actual_created_pr = VCR.use_cassette('github_com/create_pr_upstream_without_write_permissions') do
100
- # service_instance = described_class.new(upstream_repository, out: actual_output, git_client: git_client)
101
- # service_instance.execute(
102
- # 'Title', 'Description',
103
- # labels: '<ignored>',
104
- # output: actual_output
105
- # )
106
- # end
107
- #
108
- # expect(actual_output.string).to eql(expected_output)
109
- #
110
- # expect(actual_created_pr.number).to eql(9)
111
- # expect(actual_created_pr.title).to eql('Title')
112
- # expect(actual_created_pr.link).to eql('https://github.com/donald-fr/testrepo_u/pull/9')
113
- # end
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
- operation = -> do
138
+ expect do
126
139
  service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
127
- service_instance.execute('Title', 'Description', output: actual_output, automated_mode: true)
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
- # do
136
- # allow(git_client).to receive(:working_tree_clean?).and_return(true)
137
- # allow(git_client).to receive(:current_branch).and_return('mybranch')
138
- # allow(git_client).to receive(:main_branch).and_return('master')
139
- # expect(git_client).to receive(:remote_branch).and_return('mybranch')
140
- # expect(git_client).to receive(:push)
141
- #
142
- # allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
143
- #
144
- # expected_output = <<~STR
145
- # Pushing to remote branch...
146
- # Creating PR...
147
- # Assigning authenticated user...
148
- # PR address: https://github.com/donaldduck/testrepo_f/pull/2
149
- # STR
150
- #
151
- # actual_output = StringIO.new
152
- #
153
- # actual_created_pr = VCR.use_cassette('github_com/create_pr_in_auto_mode_with_push') do
154
- # service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
155
- # service_instance.execute('Title', 'Description', output: actual_output, automated_mode: true)
156
- # end
157
- #
158
- # expect(actual_output.string).to eql(expected_output)
159
- # end
160
-
161
- it "should create a remote branch, when there isn't one (is not tracked)"
162
- # do
163
- # allow(git_client).to receive(:working_tree_clean?).and_return(true)
164
- # allow(git_client).to receive(:current_branch).and_return('mybranch')
165
- # allow(git_client).to receive(:main_branch).and_return('master')
166
- # expect(git_client).to receive(:remote_branch).and_return(nil)
167
- # expect(git_client).to receive(:push).with(remote_branch: 'mybranch')
168
- #
169
- # allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
170
- #
171
- # expected_output = <<~STR
172
- # Creating remote branch "mybranch"...
173
- # Creating PR...
174
- # Assigning authenticated user...
175
- # PR address: https://github.com/donaldduck/testrepo_f/pull/4
176
- # STR
177
- #
178
- # actual_output = StringIO.new
179
- #
180
- # actual_created_pr = VCR.use_cassette('github_com/create_pr_in_auto_mode_create_upstream') do
181
- # service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
182
- # service_instance.execute('Title', 'Description', output: actual_output, automated_mode: true)
183
- # end
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
- # do
33
- # allow(git_client).to receive(:current_branch).and_return(branch)
34
- # allow(git_client).to receive(:main_branch).and_return(main_branch)
35
- # allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
36
- #
37
- # expected_pr_number = 1
38
- # expected_output = <<~STR
39
- # Finding PR with head (#{owner}:#{branch})...
40
- # Merging PR ##{expected_pr_number}...
41
- # Fetching repository...
42
- # Checking out #{main_branch}...
43
- # Rebasing...
44
- # Deleting local branch mybranch...
45
- # STR
46
- #
47
- # actual_output = StringIO.new
48
- #
49
- # service_result = VCR.use_cassette('github_com/merge_pr') do
50
- # described_class.new(repository, out: actual_output, git_client: git_client).execute
51
- # end
52
- #
53
- # actual_pr_number = service_result.number
54
- #
55
- # expect(actual_output.string).to eql(expected_output)
56
- # expect(actual_pr_number).to eql(expected_pr_number)
57
- # end
58
-
59
- it 'should merge the PR for the current branch, with branch deletion'
60
- # 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
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
- # do
94
- # allow(git_client).to receive(:current_branch).and_return(branch)
95
- # allow(git_client).to receive(:main_branch).and_return(main_branch)
96
- # allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:#{owner}/#{repository_name}")
97
- #
98
- # expected_pr_number = 4
99
- # expected_output = <<~STR
100
- # Finding PR with head (#{owner}:#{branch})...
101
- # Merging PR ##{expected_pr_number}...
102
- # Fetching repository...
103
- # Checking out #{main_branch}...
104
- # Rebasing...
105
- # Deleting local branch mybranch...
106
- # STR
107
- #
108
- # actual_output = StringIO.new
109
- #
110
- # service_result = VCR.use_cassette('gitlab_com/merge_pr') do
111
- # described_class.new(repository, out: actual_output, git_client: git_client).execute
112
- # end
113
- #
114
- # actual_pr_number = service_result.number
115
- #
116
- # expect(actual_output.string).to eql(expected_output)
117
- # expect(actual_pr_number).to eql(expected_pr_number)
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
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  require 'vcr'
6
6
  require 'base64'
7
7
 
8
- require_relative '../lib/geet/utils/attributes_selection_manager'
8
+ require_relative '../lib/geet'
9
9
 
10
10
  VCR.configure do |config|
11
11
  config.cassette_library_dir = 'spec/vcr_cassettes'