geet 0.26.0 → 0.27.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 +1 -0
- data/geet.gemspec +1 -1
- data/lib/geet/git/repository.rb +2 -2
- data/lib/geet/github/abstract_issue.rb +38 -12
- data/lib/geet/github/api_interface.rb +86 -16
- data/lib/geet/github/branch.rb +5 -1
- data/lib/geet/github/gist.rb +26 -2
- data/lib/geet/github/issue.rb +31 -5
- data/lib/geet/github/label.rb +32 -8
- data/lib/geet/github/milestone.rb +56 -11
- data/lib/geet/github/pr.rb +105 -21
- data/lib/geet/github/remote_repository.rb +19 -3
- data/lib/geet/github/user.rb +47 -11
- data/lib/geet/gitlab/api_interface.rb +85 -22
- data/lib/geet/gitlab/issue.rb +32 -5
- data/lib/geet/gitlab/label.rb +37 -8
- data/lib/geet/gitlab/milestone.rb +41 -6
- data/lib/geet/gitlab/pr.rb +60 -8
- data/lib/geet/gitlab/user.rb +27 -5
- data/lib/geet/helpers/services_workflow_helper.rb +1 -1
- data/lib/geet/services/comment_pr.rb +1 -1
- data/lib/geet/services/create_gist.rb +1 -1
- data/lib/geet/services/create_issue.rb +70 -8
- data/lib/geet/services/create_pr.rb +14 -5
- data/lib/geet/services/list_issues.rb +20 -1
- data/lib/geet/services/merge_pr.rb +1 -1
- data/lib/geet/services/open_pr.rb +16 -1
- data/lib/geet/version.rb +1 -1
- data/spec/integration/create_issue_spec.rb +1 -2
- data/spec/integration/create_pr_spec.rb +10 -10
- data/spec/spec_helper.rb +3 -0
- data/spec/unit/github/pr_spec.rb +165 -0
- metadata +3 -2
|
@@ -7,8 +7,8 @@ require_relative '../../lib/geet/services/create_pr'
|
|
|
7
7
|
|
|
8
8
|
describe Geet::Services::CreatePr do
|
|
9
9
|
let(:git_client) { Geet::Utils::GitClient.new }
|
|
10
|
-
let(:repository) { Geet::Git::Repository.new(git_client
|
|
11
|
-
let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client
|
|
10
|
+
let(:repository) { Geet::Git::Repository.new(git_client:, warnings: false) }
|
|
11
|
+
let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client:, warnings: false) }
|
|
12
12
|
|
|
13
13
|
context 'with github.com' do
|
|
14
14
|
context 'with labels, reviewers and milestones' do
|
|
@@ -37,7 +37,7 @@ describe Geet::Services::CreatePr do
|
|
|
37
37
|
actual_output = StringIO.new
|
|
38
38
|
|
|
39
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:
|
|
40
|
+
service_instance = described_class.new(repository, out: actual_output, git_client:)
|
|
41
41
|
service_instance.execute(
|
|
42
42
|
'Title', 'Description',
|
|
43
43
|
labels: 'bug,invalid', milestone: '0.0.1', reviewers: 'donald-fr'
|
|
@@ -74,7 +74,7 @@ describe Geet::Services::CreatePr do
|
|
|
74
74
|
actual_output = StringIO.new
|
|
75
75
|
|
|
76
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:
|
|
77
|
+
service_instance = described_class.new(upstream_repository, out: actual_output, git_client:)
|
|
78
78
|
service_instance.execute('Title', 'Description')
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -111,7 +111,7 @@ describe Geet::Services::CreatePr do
|
|
|
111
111
|
actual_output = StringIO.new
|
|
112
112
|
|
|
113
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:
|
|
114
|
+
service_instance = described_class.new(upstream_repository, out: actual_output, git_client:)
|
|
115
115
|
service_instance.execute(
|
|
116
116
|
'Title', 'Description',
|
|
117
117
|
labels: '<ignored>'
|
|
@@ -136,7 +136,7 @@ describe Geet::Services::CreatePr do
|
|
|
136
136
|
actual_output = StringIO.new
|
|
137
137
|
|
|
138
138
|
expect do
|
|
139
|
-
service_instance = described_class.new(repository, out: actual_output, git_client:
|
|
139
|
+
service_instance = described_class.new(repository, out: actual_output, git_client:)
|
|
140
140
|
service_instance.execute('Title', 'Description')
|
|
141
141
|
end.to raise_error(RuntimeError, 'The working tree is not clean!')
|
|
142
142
|
|
|
@@ -163,7 +163,7 @@ describe Geet::Services::CreatePr do
|
|
|
163
163
|
actual_output = StringIO.new
|
|
164
164
|
|
|
165
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:
|
|
166
|
+
service_instance = described_class.new(repository, out: actual_output, git_client:)
|
|
167
167
|
service_instance.execute('Title', 'Description')
|
|
168
168
|
end
|
|
169
169
|
|
|
@@ -188,7 +188,7 @@ describe Geet::Services::CreatePr do
|
|
|
188
188
|
actual_output = StringIO.new
|
|
189
189
|
|
|
190
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:
|
|
191
|
+
service_instance = described_class.new(repository, out: actual_output, git_client:)
|
|
192
192
|
service_instance.execute('Title', 'Description')
|
|
193
193
|
end
|
|
194
194
|
|
|
@@ -223,7 +223,7 @@ describe Geet::Services::CreatePr do
|
|
|
223
223
|
|
|
224
224
|
allow(repository).to receive(:create_pr).and_return(mock_pr)
|
|
225
225
|
|
|
226
|
-
service_instance = described_class.new(repository, out: actual_output, git_client:
|
|
226
|
+
service_instance = described_class.new(repository, out: actual_output, git_client:)
|
|
227
227
|
service_instance.execute('Title', 'Description', automerge: true)
|
|
228
228
|
|
|
229
229
|
expect(mock_pr).to have_received(:enable_automerge)
|
|
@@ -256,7 +256,7 @@ describe Geet::Services::CreatePr do
|
|
|
256
256
|
|
|
257
257
|
allow(repository).to receive(:create_pr).and_return(mock_pr)
|
|
258
258
|
|
|
259
|
-
service_instance = described_class.new(repository, out: actual_output, git_client:
|
|
259
|
+
service_instance = described_class.new(repository, out: actual_output, git_client:)
|
|
260
260
|
|
|
261
261
|
expect do
|
|
262
262
|
service_instance.execute('Title', 'Description', automerge: true)
|
data/spec/spec_helper.rb
CHANGED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# typed: false
|
|
3
|
+
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
|
|
6
|
+
require_relative '../../../lib/geet/github/pr'
|
|
7
|
+
require_relative '../../../lib/geet/github/api_interface'
|
|
8
|
+
|
|
9
|
+
describe Geet::Github::PR do
|
|
10
|
+
describe '#fetch_available_merge_method' do
|
|
11
|
+
let(:api_interface) { instance_double(Geet::Github::ApiInterface) }
|
|
12
|
+
let(:pr_number) { 123 }
|
|
13
|
+
let(:pr_title) { 'Test PR' }
|
|
14
|
+
let(:pr_link) { 'https://github.com/owner/repo/pull/123' }
|
|
15
|
+
let(:node_id) { 'PR_node_id_123' }
|
|
16
|
+
let(:repository_path) { 'owner/repo' }
|
|
17
|
+
|
|
18
|
+
subject { described_class.new(pr_number, api_interface, pr_title, pr_link, node_id: node_id) }
|
|
19
|
+
|
|
20
|
+
before do
|
|
21
|
+
allow(api_interface).to receive(:repository_path).and_return(repository_path)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'when there is one commit and squash merge is allowed' do
|
|
25
|
+
it 'returns SQUASH' do
|
|
26
|
+
graphql_response = {
|
|
27
|
+
'repository' => {
|
|
28
|
+
'mergeCommitAllowed' => true,
|
|
29
|
+
'squashMergeAllowed' => true,
|
|
30
|
+
'rebaseMergeAllowed' => true,
|
|
31
|
+
'pullRequest' => {
|
|
32
|
+
'commits' => {
|
|
33
|
+
'totalCount' => 1
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
expect(api_interface).to receive(:send_graphql_request)
|
|
40
|
+
.with(anything, variables: { owner: 'owner', name: 'repo', number: pr_number })
|
|
41
|
+
.and_return(graphql_response)
|
|
42
|
+
|
|
43
|
+
result = subject.send(:fetch_available_merge_method)
|
|
44
|
+
expect(result).to eq('SQUASH')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context 'when there is one commit but squash merge is not allowed' do
|
|
49
|
+
it 'returns MERGE if merge commit is allowed' do
|
|
50
|
+
graphql_response = {
|
|
51
|
+
'repository' => {
|
|
52
|
+
'mergeCommitAllowed' => true,
|
|
53
|
+
'squashMergeAllowed' => false,
|
|
54
|
+
'rebaseMergeAllowed' => true,
|
|
55
|
+
'pullRequest' => {
|
|
56
|
+
'commits' => {
|
|
57
|
+
'totalCount' => 1
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
expect(api_interface).to receive(:send_graphql_request)
|
|
64
|
+
.with(anything, variables: { owner: 'owner', name: 'repo', number: pr_number })
|
|
65
|
+
.and_return(graphql_response)
|
|
66
|
+
|
|
67
|
+
result = subject.send(:fetch_available_merge_method)
|
|
68
|
+
expect(result).to eq('MERGE')
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context 'when there are multiple commits and merge commit is allowed' do
|
|
73
|
+
it 'returns MERGE' do
|
|
74
|
+
graphql_response = {
|
|
75
|
+
'repository' => {
|
|
76
|
+
'mergeCommitAllowed' => true,
|
|
77
|
+
'squashMergeAllowed' => true,
|
|
78
|
+
'rebaseMergeAllowed' => true,
|
|
79
|
+
'pullRequest' => {
|
|
80
|
+
'commits' => {
|
|
81
|
+
'totalCount' => 3
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
expect(api_interface).to receive(:send_graphql_request)
|
|
88
|
+
.with(anything, variables: { owner: 'owner', name: 'repo', number: pr_number })
|
|
89
|
+
.and_return(graphql_response)
|
|
90
|
+
|
|
91
|
+
result = subject.send(:fetch_available_merge_method)
|
|
92
|
+
expect(result).to eq('MERGE')
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context 'when there are multiple commits and merge commit is not allowed' do
|
|
97
|
+
it 'returns SQUASH if squash merge is allowed' do
|
|
98
|
+
graphql_response = {
|
|
99
|
+
'repository' => {
|
|
100
|
+
'mergeCommitAllowed' => false,
|
|
101
|
+
'squashMergeAllowed' => true,
|
|
102
|
+
'rebaseMergeAllowed' => true,
|
|
103
|
+
'pullRequest' => {
|
|
104
|
+
'commits' => {
|
|
105
|
+
'totalCount' => 3
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
expect(api_interface).to receive(:send_graphql_request)
|
|
112
|
+
.with(anything, variables: { owner: 'owner', name: 'repo', number: pr_number })
|
|
113
|
+
.and_return(graphql_response)
|
|
114
|
+
|
|
115
|
+
result = subject.send(:fetch_available_merge_method)
|
|
116
|
+
expect(result).to eq('SQUASH')
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'returns REBASE if only rebase merge is allowed' do
|
|
120
|
+
graphql_response = {
|
|
121
|
+
'repository' => {
|
|
122
|
+
'mergeCommitAllowed' => false,
|
|
123
|
+
'squashMergeAllowed' => false,
|
|
124
|
+
'rebaseMergeAllowed' => true,
|
|
125
|
+
'pullRequest' => {
|
|
126
|
+
'commits' => {
|
|
127
|
+
'totalCount' => 3
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
expect(api_interface).to receive(:send_graphql_request)
|
|
134
|
+
.with(anything, variables: { owner: 'owner', name: 'repo', number: pr_number })
|
|
135
|
+
.and_return(graphql_response)
|
|
136
|
+
|
|
137
|
+
result = subject.send(:fetch_available_merge_method)
|
|
138
|
+
expect(result).to eq('REBASE')
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
context 'when no merge methods are allowed' do
|
|
143
|
+
it 'raises an error' do
|
|
144
|
+
graphql_response = {
|
|
145
|
+
'repository' => {
|
|
146
|
+
'mergeCommitAllowed' => false,
|
|
147
|
+
'squashMergeAllowed' => false,
|
|
148
|
+
'rebaseMergeAllowed' => false,
|
|
149
|
+
'pullRequest' => {
|
|
150
|
+
'commits' => {
|
|
151
|
+
'totalCount' => 3
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
expect(api_interface).to receive(:send_graphql_request)
|
|
158
|
+
.with(anything, variables: { owner: 'owner', name: 'repo', number: pr_number })
|
|
159
|
+
.and_return(graphql_response)
|
|
160
|
+
|
|
161
|
+
expect { subject.send(:fetch_available_merge_method) }.to raise_error('No merge methods are allowed on this repository')
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: geet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.27.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Saverio Miroddi
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-01-
|
|
10
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: base64
|
|
@@ -259,6 +259,7 @@ files:
|
|
|
259
259
|
- spec/integration/open_pr_spec.rb
|
|
260
260
|
- spec/integration/open_repo_spec.rb
|
|
261
261
|
- spec/spec_helper.rb
|
|
262
|
+
- spec/unit/github/pr_spec.rb
|
|
262
263
|
- spec/vcr_cassettes/create_gist_private.yml
|
|
263
264
|
- spec/vcr_cassettes/create_gist_public.yml
|
|
264
265
|
- spec/vcr_cassettes/create_issue.yml
|