geet 0.27.4 → 0.27.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee979b6b3bf1da361977e4dfa037c01d9343335e8d0467e8e2bafd44de3fde3b
4
- data.tar.gz: 1b020b81142a9871a3acfd08bed288c8a9d233c090e09d212c166ac7c1a32de3
3
+ metadata.gz: d1c3a9bd2a9883d7b36e91df67c4d1722da44c23bd65616bf2803f680064751f
4
+ data.tar.gz: 6add43b4d2d153ce50abad92764370072f9b7f656c522a0fa1e847fd6882994e
5
5
  SHA512:
6
- metadata.gz: f31eb924abe11d7930e5451e379a48a36175df4d4222f20d203af08f7e43200d765a77e0986fd3e438610d0d89c812b4709cb63b30119f7bbb345ff40908cf1a
7
- data.tar.gz: 8fca76ff21f823e9f311ba66aa97e34393b631def8d89f1f3f4ec3bc0d0630492e0c530ae957230761f4166e5d447229824f57c55afe6739b721e8a4c0d31a1e
6
+ metadata.gz: 4937ad46f92405c41a51d4fba4be6266d20a6e0a3d4186e6fa572cd77361b9b58cf55617bf9ad33bf564771a0e807789ddd6d49485eaaf1ec530a128b87ec6ae
7
+ data.tar.gz: 4db96d9d5df4217c74e33109a18827c063af224bb7c88e175041e36c01f75cac644165d7f12790f07e4a4ed20011446209d23bbc75a165fbc22b5151902fa5bb
@@ -44,7 +44,7 @@ module Geet
44
44
  response = T.cast(api_interface.send_request(api_path), T::Hash[String, T.untyped])
45
45
 
46
46
  parent_hash = T.cast(response["parent"], T.nilable(T::Hash[String, T.untyped]))
47
- parent_path = T.cast(parent_hash&.fetch("full_name)"), T.nilable(String))
47
+ parent_path = T.cast(parent_hash&.fetch("full_name"), T.nilable(String))
48
48
 
49
49
  new(api_interface, parent_path:)
50
50
  end
data/lib/geet/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # typed: strict
3
3
 
4
4
  module Geet
5
- VERSION = "0.27.4"
5
+ VERSION = "0.27.5"
6
6
  end
@@ -81,6 +81,43 @@ describe Geet::Services::CreatePr do
81
81
  }.to output(expected_output).to_stdout
82
82
  end
83
83
 
84
+ it "should add upstream remote when not defined" do
85
+ downstream_repo = Geet::Git::Repository.new(upstream: false, git_client:, warnings: false)
86
+
87
+ allow(git_client).to receive(:working_tree_clean?).and_return(true)
88
+ allow(git_client).to receive(:current_branch).and_return("mybranch")
89
+ allow(git_client).to receive(:main_branch).and_return("master")
90
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/testrepo_f")
91
+ allow(git_client).to receive(:remote_defined?).with("upstream").and_return(false)
92
+ allow(git_client).to receive(:path).with(upstream: false).and_return("donaldduck/testrepo_f")
93
+ allow(git_client).to receive(:path).with(upstream: true).and_return("donald-fr/testrepo_u")
94
+ allow(upstream_repository).to receive(:downstream).and_return(downstream_repo)
95
+ expect(git_client).to receive(:add_remote).with("upstream", "git@github.com:donald-fr/testrepo_u.git")
96
+ allow(git_client).to receive(:remote_branch).and_return("mybranch")
97
+ expect(git_client).to receive(:fetch)
98
+ allow(git_client).to receive(:remote_branch_diff_commits).and_return([])
99
+ expect(git_client).to receive(:push)
100
+ allow(git_client).to receive(:remote_components).and_return(["git@", "github.com", ":", "donaldduck/testrepo_f", ".git"])
101
+
102
+ expected_output = <<~STR
103
+ Upstream not found; adding it to the repository remotes...
104
+ Pushing to remote branch...
105
+ Creating PR...
106
+ PR address: https://github.com/donald-fr/testrepo_u/pull/10
107
+ STR
108
+
109
+ expect {
110
+ actual_created_pr = VCR.use_cassette("github_com/create_pr_upstream_add_remote", allow_unused_http_interactions: true) do
111
+ service_instance = described_class.new(upstream_repository, git_client:)
112
+ service_instance.execute("Title", "Description")
113
+ end
114
+
115
+ expect(actual_created_pr.number).to eql(10)
116
+ expect(actual_created_pr.title).to eql("Title")
117
+ expect(actual_created_pr.link).to eql("https://github.com/donald-fr/testrepo_u/pull/10")
118
+ }.to output(expected_output).to_stdout
119
+ end
120
+
84
121
  # It would be more consistent to have this UT outside of an upstream context, however this use
85
122
  # case is actually a typical real-world one
86
123
  #
@@ -0,0 +1,359 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/repos/donaldduck/testrepo_f
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/vnd.github.v3+json
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.github.com
18
+ Authorization:
19
+ - Basic <GITHUB_CREDENTIALS>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - GitHub.com
27
+ Date:
28
+ - Mon, 05 Feb 2018 21:10:32 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Status:
32
+ - 200 OK
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"id":123456,"name":"testrepo_f","full_name":"donaldduck/testrepo_f","owner":{"login":"donaldduck","id":123456},"private":false,"html_url":"https://github.com/donaldduck/testrepo_f","description":null,"fork":true,"url":"https://api.github.com/repos/donaldduck/testrepo_f","parent":{"id":789012,"name":"testrepo_u","full_name":"donald-fr/testrepo_u","owner":{"login":"donald-fr","id":789012},"private":false,"html_url":"https://github.com/donald-fr/testrepo_u","description":null,"fork":false},"created_at":"2018-02-05T20:44:53Z","updated_at":"2018-02-05T21:04:59Z","pushed_at":"2018-02-05T21:07:31Z","git_url":"git://github.com/donaldduck/testrepo_f.git","ssh_url":"git@github.com:donaldduck/testrepo_f.git","clone_url":"https://github.com/donaldduck/testrepo_f.git","default_branch":"master"}'
36
+ http_version:
37
+ recorded_at: Mon, 05 Feb 2018 21:10:32 GMT
38
+ - request:
39
+ method: get
40
+ uri: https://api.github.com/user
41
+ body:
42
+ encoding: US-ASCII
43
+ string: ''
44
+ headers:
45
+ Accept-Encoding:
46
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
47
+ Accept:
48
+ - application/vnd.github.v3+json
49
+ User-Agent:
50
+ - Ruby
51
+ Host:
52
+ - api.github.com
53
+ Authorization:
54
+ - Basic <GITHUB_CREDENTIALS>
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: OK
59
+ headers:
60
+ Server:
61
+ - GitHub.com
62
+ Date:
63
+ - Mon, 05 Feb 2018 21:10:32 GMT
64
+ Content-Type:
65
+ - application/json; charset=utf-8
66
+ Transfer-Encoding:
67
+ - chunked
68
+ Status:
69
+ - 200 OK
70
+ X-Ratelimit-Limit:
71
+ - '5000'
72
+ X-Ratelimit-Remaining:
73
+ - '4975'
74
+ X-Ratelimit-Reset:
75
+ - '1517867477'
76
+ body:
77
+ encoding: ASCII-8BIT
78
+ string: '{"login":"donaldduck","id":123456,"avatar_url":"https://avatars2.githubusercontent.com/u/123456?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldduck","html_url":"https://github.com/donaldduck","type":"User","site_admin":false,"name":"Donald Duck","email":"donald.pub2@gmail.com"}'
79
+ http_version:
80
+ recorded_at: Mon, 05 Feb 2018 21:10:32 GMT
81
+ - request:
82
+ method: get
83
+ uri: https://api.github.com/repos/donald-fr/testrepo_u/collaborators/donaldduck
84
+ body:
85
+ encoding: US-ASCII
86
+ string: ''
87
+ headers:
88
+ Accept-Encoding:
89
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
90
+ Accept:
91
+ - application/vnd.github.v3+json
92
+ User-Agent:
93
+ - Ruby
94
+ Host:
95
+ - api.github.com
96
+ Authorization:
97
+ - Basic <GITHUB_CREDENTIALS>
98
+ response:
99
+ status:
100
+ code: 204
101
+ message: No Content
102
+ headers:
103
+ Server:
104
+ - GitHub.com
105
+ Date:
106
+ - Mon, 05 Feb 2018 21:10:33 GMT
107
+ Status:
108
+ - 204 No Content
109
+ body:
110
+ encoding: UTF-8
111
+ string: ''
112
+ http_version:
113
+ recorded_at: Mon, 05 Feb 2018 21:10:33 GMT
114
+ - request:
115
+ method: get
116
+ uri: https://api.github.com/user
117
+ body:
118
+ encoding: US-ASCII
119
+ string: ''
120
+ headers:
121
+ Accept-Encoding:
122
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
123
+ Accept:
124
+ - application/vnd.github.v3+json
125
+ User-Agent:
126
+ - Ruby
127
+ Host:
128
+ - api.github.com
129
+ Authorization:
130
+ - Basic <GITHUB_CREDENTIALS>
131
+ response:
132
+ status:
133
+ code: 200
134
+ message: OK
135
+ headers:
136
+ Server:
137
+ - GitHub.com
138
+ Date:
139
+ - Mon, 05 Feb 2018 21:10:35 GMT
140
+ Content-Type:
141
+ - application/json; charset=utf-8
142
+ Status:
143
+ - 200 OK
144
+ body:
145
+ encoding: ASCII-8BIT
146
+ string: '{"login":"donaldduck","id":123456,"avatar_url":"https://avatars2.githubusercontent.com/u/123456?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldduck","html_url":"https://github.com/donaldduck","type":"User","site_admin":false,"name":"Donald Duck","email":"donald.pub2@gmail.com"}'
147
+ http_version:
148
+ recorded_at: Mon, 05 Feb 2018 21:10:35 GMT
149
+ - request:
150
+ method: get
151
+ uri: https://api.github.com/user
152
+ body:
153
+ encoding: US-ASCII
154
+ string: ''
155
+ headers:
156
+ Accept-Encoding:
157
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
158
+ Accept:
159
+ - application/vnd.github.v3+json
160
+ User-Agent:
161
+ - Ruby
162
+ Host:
163
+ - api.github.com
164
+ Authorization:
165
+ - Basic <GITHUB_CREDENTIALS>
166
+ response:
167
+ status:
168
+ code: 200
169
+ message: OK
170
+ headers:
171
+ Server:
172
+ - GitHub.com
173
+ Date:
174
+ - Mon, 05 Feb 2018 21:10:36 GMT
175
+ Content-Type:
176
+ - application/json; charset=utf-8
177
+ Status:
178
+ - 200 OK
179
+ body:
180
+ encoding: ASCII-8BIT
181
+ string: '{"login":"donaldduck","id":123456,"avatar_url":"https://avatars2.githubusercontent.com/u/123456?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldduck","html_url":"https://github.com/donaldduck","type":"User","site_admin":false,"name":"Donald Duck","email":"donald.pub2@gmail.com"}'
182
+ http_version:
183
+ recorded_at: Mon, 05 Feb 2018 21:10:36 GMT
184
+ - request:
185
+ method: get
186
+ uri: https://api.github.com/repos/donald-fr/testrepo_u/collaborators/donaldduck/permission
187
+ body:
188
+ encoding: US-ASCII
189
+ string: ''
190
+ headers:
191
+ Accept-Encoding:
192
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
193
+ Accept:
194
+ - application/vnd.github.v3+json
195
+ User-Agent:
196
+ - Ruby
197
+ Host:
198
+ - api.github.com
199
+ Authorization:
200
+ - Basic <GITHUB_CREDENTIALS>
201
+ response:
202
+ status:
203
+ code: 200
204
+ message: OK
205
+ headers:
206
+ Server:
207
+ - GitHub.com
208
+ Date:
209
+ - Mon, 05 Feb 2018 21:10:37 GMT
210
+ Content-Type:
211
+ - application/json; charset=utf-8
212
+ Status:
213
+ - 200 OK
214
+ body:
215
+ encoding: ASCII-8BIT
216
+ string: '{"permission":"write","user":{"login":"donaldduck","id":123456,"avatar_url":"https://avatars2.githubusercontent.com/u/123456?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldduck","html_url":"https://github.com/donaldduck","type":"User","site_admin":false}}'
217
+ http_version:
218
+ recorded_at: Mon, 05 Feb 2018 21:10:37 GMT
219
+ - request:
220
+ method: get
221
+ uri: https://api.github.com/user
222
+ body:
223
+ encoding: US-ASCII
224
+ string: ''
225
+ headers:
226
+ Accept-Encoding:
227
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
228
+ Accept:
229
+ - application/vnd.github.v3+json
230
+ User-Agent:
231
+ - Ruby
232
+ Host:
233
+ - api.github.com
234
+ Authorization:
235
+ - Basic <GITHUB_CREDENTIALS>
236
+ response:
237
+ status:
238
+ code: 200
239
+ message: OK
240
+ headers:
241
+ Server:
242
+ - GitHub.com
243
+ Date:
244
+ - Mon, 05 Feb 2018 21:10:38 GMT
245
+ Content-Type:
246
+ - application/json; charset=utf-8
247
+ Status:
248
+ - 200 OK
249
+ body:
250
+ encoding: ASCII-8BIT
251
+ string: '{"login":"donaldduck","id":123456,"avatar_url":"https://avatars2.githubusercontent.com/u/123456?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldduck","html_url":"https://github.com/donaldduck","type":"User","site_admin":false,"name":"Donald Duck","email":"donald.pub2@gmail.com"}'
252
+ http_version:
253
+ recorded_at: Mon, 05 Feb 2018 21:10:38 GMT
254
+ - request:
255
+ method: post
256
+ uri: https://api.github.com/repos/donald-fr/testrepo_u/pulls
257
+ body:
258
+ encoding: UTF-8
259
+ string: '{"title":"Title","body":"Description","head":"donaldduck:mybranch","base":"master","draft":false}'
260
+ headers:
261
+ Accept-Encoding:
262
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
263
+ Accept:
264
+ - application/vnd.github.v3+json
265
+ User-Agent:
266
+ - Ruby
267
+ Host:
268
+ - api.github.com
269
+ Authorization:
270
+ - Basic <GITHUB_CREDENTIALS>
271
+ response:
272
+ status:
273
+ code: 201
274
+ message: Created
275
+ headers:
276
+ Server:
277
+ - GitHub.com
278
+ Date:
279
+ - Mon, 05 Feb 2018 21:10:40 GMT
280
+ Content-Type:
281
+ - application/json; charset=utf-8
282
+ Status:
283
+ - 201 Created
284
+ body:
285
+ encoding: UTF-8
286
+ string: '{"url":"https://api.github.com/repos/donald-fr/testrepo_u/pulls/10","id":123457,"html_url":"https://github.com/donald-fr/testrepo_u/pull/10","number":10,"state":"open","locked":false,"title":"Title","user":{"login":"donaldduck","id":123456},"body":"Description","created_at":"2018-02-05T21:10:39Z","updated_at":"2018-02-05T21:10:39Z","head":{"label":"donaldduck:mybranch","ref":"mybranch","repo":{"id":123456,"name":"testrepo_f","full_name":"donaldduck/testrepo_f","fork":true}},"base":{"label":"donald-fr:master","ref":"master","repo":{"id":789012,"name":"testrepo_u","full_name":"donald-fr/testrepo_u","fork":false}},"merged":false}'
287
+ http_version:
288
+ recorded_at: Mon, 05 Feb 2018 21:10:40 GMT
289
+ - request:
290
+ method: get
291
+ uri: https://api.github.com/user
292
+ body:
293
+ encoding: US-ASCII
294
+ string: ''
295
+ headers:
296
+ Accept-Encoding:
297
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
298
+ Accept:
299
+ - application/vnd.github.v3+json
300
+ User-Agent:
301
+ - Ruby
302
+ Host:
303
+ - api.github.com
304
+ Authorization:
305
+ - Basic <GITHUB_CREDENTIALS>
306
+ response:
307
+ status:
308
+ code: 200
309
+ message: OK
310
+ headers:
311
+ Server:
312
+ - GitHub.com
313
+ Date:
314
+ - Mon, 05 Feb 2018 21:10:41 GMT
315
+ Content-Type:
316
+ - application/json; charset=utf-8
317
+ Status:
318
+ - 200 OK
319
+ body:
320
+ encoding: ASCII-8BIT
321
+ string: '{"login":"donaldduck","id":123456,"avatar_url":"https://avatars2.githubusercontent.com/u/123456?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldduck","html_url":"https://github.com/donaldduck","type":"User","site_admin":false,"name":"Donald Duck","email":"donald.pub2@gmail.com"}'
322
+ http_version:
323
+ recorded_at: Mon, 05 Feb 2018 21:10:41 GMT
324
+ - request:
325
+ method: post
326
+ uri: https://api.github.com/repos/donald-fr/testrepo_u/issues/10/assignees
327
+ body:
328
+ encoding: UTF-8
329
+ string: '{"assignees":["donaldduck"]}'
330
+ headers:
331
+ Accept-Encoding:
332
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
333
+ Accept:
334
+ - application/vnd.github.v3+json
335
+ User-Agent:
336
+ - Ruby
337
+ Host:
338
+ - api.github.com
339
+ Authorization:
340
+ - Basic <GITHUB_CREDENTIALS>
341
+ response:
342
+ status:
343
+ code: 201
344
+ message: Created
345
+ headers:
346
+ Server:
347
+ - GitHub.com
348
+ Date:
349
+ - Mon, 05 Feb 2018 21:10:42 GMT
350
+ Content-Type:
351
+ - application/json; charset=utf-8
352
+ Status:
353
+ - 201 Created
354
+ body:
355
+ encoding: UTF-8
356
+ string: '{"url":"https://api.github.com/repos/donald-fr/testrepo_u/issues/10","number":10,"title":"Title","user":{"login":"donaldduck","id":123456},"state":"open","assignee":{"login":"donaldduck","id":123456},"assignees":[{"login":"donaldduck","id":123456}],"body":"Description","pull_request":{"url":"https://api.github.com/repos/donald-fr/testrepo_u/pulls/10","html_url":"https://github.com/donald-fr/testrepo_u/pull/10"}}'
357
+ http_version:
358
+ recorded_at: Mon, 05 Feb 2018 21:10:42 GMT
359
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.4
4
+ version: 0.27.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saverio Miroddi
@@ -272,6 +272,7 @@ files:
272
272
  - spec/vcr_cassettes/github_com/create_pr_in_auto_mode_create_upstream.yml
273
273
  - spec/vcr_cassettes/github_com/create_pr_in_auto_mode_with_push.yml
274
274
  - spec/vcr_cassettes/github_com/create_pr_upstream.yml
275
+ - spec/vcr_cassettes/github_com/create_pr_upstream_add_remote.yml
275
276
  - spec/vcr_cassettes/github_com/create_pr_upstream_without_write_permissions.yml
276
277
  - spec/vcr_cassettes/github_com/list_issues.yml
277
278
  - spec/vcr_cassettes/github_com/list_issues_upstream.yml