git-fastclone 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9383bab9258efe9c7f106182b92ffbe0a66031a799f61313286c5525353a6676
4
- data.tar.gz: f8611d4f1c8afc78b1fb0a65af35e386b5c7ecdfe9b8bafe36c391670e2f4622
3
+ metadata.gz: b66c5e0946f4cfae0ecb36ac298f9b6e76e85a829ee17fd8a3425c92468e3c8d
4
+ data.tar.gz: 3364449b9348575acf9ec4dfd2f73883e19e634340d35a0aa8df9ffe4f9c3aaf
5
5
  SHA512:
6
- metadata.gz: 4182af8e5b3e978167466329df3fceb3e0b14808e71425d121d447bb84b0d37490eae4cad9a8c1c8b05f4fecdc1bc0e9da2a5743fd6d761bd6c33e66d2fa5dd7
7
- data.tar.gz: 42fb710ef3ec9ab6eae8c7f176ea4f4dffca799326b590130c4c8fc8649430f9f367ffa9edbbebeb7db89ec272620750c5368d681f57dcb05f79e4be64156fca
6
+ metadata.gz: 04a9315f022dba1cdb0ac34dd4daa768d9c19a1cbdb7eea3767098e8bc120e1a5ad2676c0e9791dc964f0b4fabd373b8d807faecbd9a4dde243ab1e97f927f5b
7
+ data.tar.gz: 96ea39ac905ac8f512322a03c3556acdd8d13174d9b5ad8591ab8ee73ea12f679c7481817e099d3300ccfea714977b9b72e93efd9148f7a878035dd8c68f4b6f
data/lib/git-fastclone.rb CHANGED
@@ -346,7 +346,25 @@ module GitFastClone
346
346
  # ended up doing the update is done with its housekeeping.
347
347
  # This makes sure we have control and unlock when the block returns:
348
348
  with_reference_repo_lock(url) do
349
- yield reference_repo_dir(url, reference_dir, using_local_repo)
349
+ dir = reference_repo_dir(url, reference_dir, using_local_repo)
350
+ retries_left = 1
351
+
352
+ begin
353
+ yield dir
354
+ rescue Terrapin::ExitStatusError => e
355
+ if e.to_s =~ /^STDERR:\n.+^fatal: (missing blob object|remote did not send all necessary objects)/m
356
+ # To avoid corruption of the cache, if we failed to update or check out we remove
357
+ # the cache directory entirely. This may cause the current clone to fail, but if the
358
+ # underlying error from git is transient it will not affect future clones.
359
+ FileUtils.remove_entry_secure(dir, force: true)
360
+ if retries_left > 0
361
+ retries_left -= 1
362
+ retry
363
+ end
364
+ end
365
+
366
+ raise
367
+ end
350
368
  end
351
369
  end
352
370
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Version string for git-fastclone
4
4
  module GitFastCloneVersion
5
- VERSION = '1.2.0'.freeze
5
+ VERSION = '1.2.1'.freeze
6
6
  end
@@ -279,5 +279,31 @@ describe GitFastClone::Runner do
279
279
 
280
280
  expect(yielded).to eq([test_url_valid])
281
281
  end
282
+
283
+ it 'should retry when the cache looks corrupted' do
284
+ allow(subject).to receive(:update_reference_repo) {}
285
+ expect(subject).to receive(:reference_repo_dir)
286
+ expect(subject).to receive(:reference_repo_lock_file).and_return(lockfile)
287
+
288
+ responses = [
289
+ lambda { |_url|
290
+ raise Terrapin::ExitStatusError, <<-ERROR.gsub(/^ {12}/, '')
291
+ STDOUT:
292
+
293
+ STDERR:
294
+
295
+ fatal: bad object ee35b1e14e7c3a53dcc14d82606e5b872f6a05a7
296
+ fatal: remote did not send all necessary objects
297
+ ERROR
298
+ },
299
+ ->(url) { url }
300
+ ]
301
+ subject.with_git_mirror(test_url_valid) do
302
+ yielded << responses.shift.call(test_url_valid)
303
+ end
304
+
305
+ expect(responses).to be_empty
306
+ expect(yielded).to eq([test_url_valid])
307
+ end
282
308
  end
283
309
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-fastclone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Tauraso
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-17 00:00:00.000000000 Z
12
+ date: 2019-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.0.2
80
+ rubygems_version: 3.0.1
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: git-clone --recursive on steroids!