Skip to content

Commit

Permalink
Retry when deltas are missing
Browse files Browse the repository at this point in the history
This error is another symptom of a broken cache and should behandled the same way as the rest of our broken cache mitigation.
  • Loading branch information
Jenn Kaplan committed Aug 15, 2019
1 parent 29b6646 commit 931d1be
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ Metrics/LineLength:

Metrics/MethodLength:
Max: 2000

Metrics/BlockLength:
Exclude:
- 'spec/**/*'
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
git-fastclone (1.2.1)
git-fastclone (1.2.2)
colorize
terrapin (~> 0.6.0)

Expand Down
7 changes: 6 additions & 1 deletion lib/git-fastclone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,12 @@ def with_git_mirror(url)
begin
yield dir
rescue Terrapin::ExitStatusError => e
if e.to_s =~ /^STDERR:\n.+^fatal: (missing blob object|remote did not send all necessary objects)/m
error_strings = [
'missing blob object',
'remote did not send all necessary objects',
/pack has \d+ unresolved deltas/
]
if e.to_s =~ /^STDERR:\n.+^fatal: #{Regexp.union(error_strings)}/m
# To avoid corruption of the cache, if we failed to update or check out we remove
# the cache directory entirely. This may cause the current clone to fail, but if the
# underlying error from git is transient it will not affect future clones.
Expand Down
2 changes: 1 addition & 1 deletion lib/git-fastclone/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Version string for git-fastclone
module GitFastCloneVersion
VERSION = '1.2.1'.freeze
VERSION = '1.2.2'.freeze
end
27 changes: 27 additions & 0 deletions spec/git_fastclone_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,32 @@
expect(responses).to be_empty
expect(yielded).to eq([test_url_valid])
end

it 'should retry when deltas are missing' do
allow(subject).to receive(:update_reference_repo) {}
expect(subject).to receive(:reference_repo_dir)
expect(subject).to receive(:reference_repo_lock_file).and_return(lockfile)

responses = [
lambda { |_url|
raise Terrapin::ExitStatusError, <<-ERROR.gsub(/^ {12}/, '')
STDOUT:
STDERR:
error: Could not read f7fad86d06fee0678f9af7203b6031feabb40c3e
fatal: pack has 138063 unresolved deltas
fatal: index-pack failed
ERROR
},
->(url) { url }
]
subject.with_git_mirror(test_url_valid) do
yielded << responses.shift.call(test_url_valid)
end

expect(responses).to be_empty
expect(yielded).to eq([test_url_valid])
end
end
end

0 comments on commit 931d1be

Please sign in to comment.