shipit-engine 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/shipit/commit.rb +2 -1
- data/app/models/shipit/stack.rb +22 -1
- data/lib/shipit/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/models/stacks_test.rb +21 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a76aee01307d253747b6e49c6c7be3bb4c3cf2
|
4
|
+
data.tar.gz: 511372e610c0dfcdad6038607733841ee2752d0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8a88d84aa2f2d6e845fadad57c9aa39ebb78986f60ccd351a502bc6f5753c9a17e99bb7e3baf2c5b9e9c6fe716d3358c65bf704c7dbf4bffed69ae5c8595f3
|
7
|
+
data.tar.gz: d9bf4e7c3550d38705f5482971f84177eb64cddc42248e42c5197009d6fa12bbdc0914360c722fa7298b4d596e7e8a0c44f00d3af8ba2c2f4cbb0c119e222ae9
|
data/app/models/shipit/commit.rb
CHANGED
@@ -80,7 +80,8 @@ module Shipit
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def refresh_statuses!
|
83
|
-
Shipit.github_api.statuses(github_repo_name, sha)
|
83
|
+
github_statuses = stack.handle_github_redirections { Shipit.github_api.statuses(github_repo_name, sha) }
|
84
|
+
github_statuses.each do |status|
|
84
85
|
statuses.replicate_from_github!(status)
|
85
86
|
end
|
86
87
|
end
|
data/app/models/shipit/stack.rb
CHANGED
@@ -215,7 +215,28 @@ module Shipit
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def github_commits
|
218
|
-
|
218
|
+
handle_github_redirections do
|
219
|
+
Shipit.github_api.commits(github_repo_name, sha: branch)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def handle_github_redirections
|
224
|
+
# https://developer.github.com/v3/#http-redirects
|
225
|
+
resource = yield
|
226
|
+
if resource.try(:message) == 'Moved Permanently'
|
227
|
+
refresh_repository!
|
228
|
+
yield
|
229
|
+
else
|
230
|
+
resource
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def refresh_repository!
|
235
|
+
resource = Shipit.github_api.repo(github_repo_name)
|
236
|
+
if resource.try(:message) == 'Moved Permanently'
|
237
|
+
resource = Shipit.github_api.get(resource.url)
|
238
|
+
end
|
239
|
+
update!(repo_owner: resource.owner.login, repo_name: resource.name)
|
219
240
|
end
|
220
241
|
|
221
242
|
def active_task?
|
data/lib/shipit/version.rb
CHANGED
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/test/models/stacks_test.rb
CHANGED
@@ -417,5 +417,26 @@ module Shipit
|
|
417
417
|
|
418
418
|
assert_equal 'pending', @stack.merge_status
|
419
419
|
end
|
420
|
+
|
421
|
+
test "#handle_github_redirections update the stack if the repository was renamed" do
|
422
|
+
repo_permalink = 'https://api.github.com/repositories/42'
|
423
|
+
|
424
|
+
commits_redirection = stub(message: 'Moved Permanently', url: File.join(repo_permalink, '/commits'))
|
425
|
+
Shipit.github_api.expects(:commits).with(@stack.github_repo_name, sha: 'master').returns(commits_redirection)
|
426
|
+
|
427
|
+
repo_redirection = stub(message: 'Moved Permanently', url: repo_permalink)
|
428
|
+
Shipit.github_api.expects(:repo).with('shopify/shipit-engine').returns(repo_redirection)
|
429
|
+
|
430
|
+
repo_resource = stub(name: 'shipster', owner: stub(login: 'george'))
|
431
|
+
Shipit.github_api.expects(:get).with(repo_permalink).returns(repo_resource)
|
432
|
+
|
433
|
+
commits_resource = stub
|
434
|
+
Shipit.github_api.expects(:commits).with('george/shipster', sha: 'master').returns(commits_resource)
|
435
|
+
|
436
|
+
assert_equal 'shopify/shipit-engine', @stack.github_repo_name
|
437
|
+
assert_equal commits_resource, @stack.github_commits
|
438
|
+
@stack.reload
|
439
|
+
assert_equal 'george/shipster', @stack.github_repo_name
|
440
|
+
end
|
420
441
|
end
|
421
442
|
end
|