Skip to content

Commit c991ff8

Browse files
author
Justin Martin
authored
Merge pull request square#40 from square/jmartin/add-cache-clean-retry-failure-mode
Add a new automatic cache clean failure mode 'did not receive expected object'
2 parents 47fbd43 + c4c1de2 commit c991ff8

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ language:
44
rvm:
55
- 2.3.1
66
- 2.6.1
7+
8+
before_install:
9+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
10+
- gem install bundler -v '< 2.0'

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
git-fastclone (1.2.4)
4+
git-fastclone (1.2.5)
55
colorize
66
terrapin (~> 0.6.0)
77

lib/git-fastclone.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ def with_git_mirror(url)
357357
'fatal: remote did not send all necessary objects',
358358
/fatal: packed object [a-z0-9]+ \(stored in .*?\) is corrupt/,
359359
/fatal: pack has \d+ unresolved deltas/,
360-
'error: unable to read sha1 file of '
360+
'error: unable to read sha1 file of ',
361+
'fatal: did not receive expected object'
361362
]
362363
if e.to_s =~ /^STDERR:\n.+^#{Regexp.union(error_strings)}/m
363364
# To avoid corruption of the cache, if we failed to update or check out we remove

lib/git-fastclone/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Version string for git-fastclone
44
module GitFastCloneVersion
5-
VERSION = '1.2.4'.freeze
5+
VERSION = '1.2.5'.freeze
66
end

spec/git_fastclone_runner_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,4 +389,32 @@
389389
expect(responses).to be_empty
390390
expect(yielded).to eq([test_url_valid])
391391
end
392+
393+
it 'should retry when the cache errors with did not receive expected object' do
394+
allow(subject).to receive(:update_reference_repo) {}
395+
expect(subject).to receive(:reference_repo_dir)
396+
expect(subject).to receive(:reference_repo_lock_file).and_return(lockfile)
397+
398+
responses = [
399+
lambda { |_url|
400+
raise Terrapin::ExitStatusError, <<-ERROR.gsub(/^ {12}/, '')
401+
STDOUT:
402+
403+
STDERR:
404+
405+
error: Could not read 6682dfe81f66656436e60883dd795e7ec6735153
406+
error: Could not read 0cd3703c23fa44c0043d97fbc26356a23939f31b
407+
fatal: did not receive expected object 3c64c9dd49c79bd09aa13d4b05ac18263ca29ccd
408+
fatal: index-pack failed
409+
ERROR
410+
},
411+
->(url) { url }
412+
]
413+
subject.with_git_mirror(test_url_valid) do
414+
yielded << responses.shift.call(test_url_valid)
415+
end
416+
417+
expect(responses).to be_empty
418+
expect(yielded).to eq([test_url_valid])
419+
end
392420
end

0 commit comments

Comments
 (0)