git-fastclone 1.4.2 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -19
- data/lib/git-fastclone/version.rb +1 -1
- data/lib/git-fastclone.rb +24 -21
- data/spec/git_fastclone_runner_spec.rb +17 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7330529bf940f74fcdf782fa298d7de00d0f75b5ccbd303bb6a99d57668b6a0
|
4
|
+
data.tar.gz: 4dc5b12076314094bf03638433dcbc6df5f486b6b2b5da6ff2350c77942b23ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ce186a25e7acbc07735118a7a9d55bbca2deee8ff7ba79ea8eebdb1dd8ecff2a01beb640528af0ed8d35a9a62bf03161b8afa545ca6ceb5b7b3ea62ce510ba
|
7
|
+
data.tar.gz: f6d0ec9167c8dc69ebdd7caad9c24d595bfd83c3400618d8eefaeb1e0ace4f6dc7a1eb4a752bb499f3c2dc16edf522096e4680dd69f414dcbef6dd9bc9addcd3
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ It aggressively updates these mirrors from origin and then clones from the mirro
|
|
35
35
|
directory of your choosing. It always works recursively and multithreaded to get your checkout up as
|
36
36
|
fast as possible.
|
37
37
|
|
38
|
-
Detailed explanation [here]
|
38
|
+
Detailed explanation [here](https://developer.squareup.com/blog/introducing-git-fastclone/).
|
39
39
|
|
40
40
|
|
41
41
|
Usage
|
@@ -71,7 +71,7 @@ requests.
|
|
71
71
|
When submitting code, please make every effort to follow existing conventions and style in order to
|
72
72
|
keep the code as readable as possible.
|
73
73
|
|
74
|
-
Before accepting any pull requests, we need you to sign an [Individual Contributor Agreement]
|
74
|
+
Before accepting any pull requests, we need you to sign an [Individual Contributor Agreement](https://docs.google.com/a/squareup.com/forms/d/13WR8m5uZ2nAkJH41k7GdVBXAAbzDk00vxtEYjd6Imzg/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1)
|
75
75
|
(Google form).
|
76
76
|
|
77
77
|
Once landed, please reach out to any owner listed in https://rubygems.org/gems/git-fastclone and ask them to help publish the new version.
|
@@ -79,15 +79,10 @@ Once landed, please reach out to any owner listed in https://rubygems.org/gems/g
|
|
79
79
|
|
80
80
|
Acknowledgements
|
81
81
|
----------------
|
82
|
-
[
|
83
|
-
|
84
|
-
[
|
85
|
-
|
86
|
-
[ianchesal][5]
|
87
|
-
|
88
|
-
[mtauraso][6]
|
89
|
-
|
90
|
-
[chriseckhardt][7]
|
82
|
+
* [robolson](https://github.com/robolson)
|
83
|
+
* [ianchesal](https://github.com/ianchesal)
|
84
|
+
* [mtauraso](https://github.com/mtauraso)
|
85
|
+
* [chriseckhardt](https://github.com/chriseckhardt)
|
91
86
|
|
92
87
|
|
93
88
|
License
|
@@ -105,11 +100,3 @@ License
|
|
105
100
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
106
101
|
See the License for the specific language governing permissions and
|
107
102
|
limitations under the License.
|
108
|
-
|
109
|
-
[1]: https://corner.squareup.com/2015/11/fastclone.html
|
110
|
-
[2]: https://docs.google.com/a/squareup.com/forms/d/13WR8m5uZ2nAkJH41k7GdVBXAAbzDk00vxtEYjd6Imzg/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
|
111
|
-
[3]: https://github.com/thoughtbot/terrapin
|
112
|
-
[4]: https://github.com/robolson
|
113
|
-
[5]: https://github.com/ianchesal
|
114
|
-
[6]: https://github.com/mtauraso
|
115
|
-
[7]: https://github.com/chriseckhardt
|
data/lib/git-fastclone.rb
CHANGED
@@ -110,7 +110,7 @@ module GitFastClone
|
|
110
110
|
def run
|
111
111
|
url, path, options = parse_inputs
|
112
112
|
|
113
|
-
require_relative '
|
113
|
+
require_relative 'git-fastclone/version'
|
114
114
|
msg = "git-fastclone #{GitFastCloneVersion::VERSION}"
|
115
115
|
if color
|
116
116
|
puts msg.yellow
|
@@ -225,10 +225,9 @@ module GitFastClone
|
|
225
225
|
|
226
226
|
# Only checkout if we're changing branches to a non-default branch
|
227
227
|
if rev
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
end
|
228
|
+
fail_on_error('git', 'checkout', '--quiet', rev.to_s, quiet: !verbose,
|
229
|
+
print_on_failure: print_git_errors,
|
230
|
+
chdir: File.join(abs_clone_path, src_dir))
|
232
231
|
end
|
233
232
|
|
234
233
|
update_submodules(src_dir, url)
|
@@ -250,11 +249,9 @@ module GitFastClone
|
|
250
249
|
|
251
250
|
threads = []
|
252
251
|
submodule_url_list = []
|
253
|
-
output = ''
|
254
|
-
|
255
|
-
|
256
|
-
print_on_failure: print_git_errors)
|
257
|
-
end
|
252
|
+
output = fail_on_error('git', 'submodule', 'init', quiet: !verbose,
|
253
|
+
print_on_failure: print_git_errors,
|
254
|
+
chdir: File.join(abs_clone_path, pwd))
|
258
255
|
|
259
256
|
output.split("\n").each do |line|
|
260
257
|
submodule_path, submodule_url = parse_update_info(line)
|
@@ -270,11 +267,10 @@ module GitFastClone
|
|
270
267
|
def thread_update_submodule(submodule_url, submodule_path, threads, pwd)
|
271
268
|
threads << Thread.new do
|
272
269
|
with_git_mirror(submodule_url) do |mirror, _|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
end
|
270
|
+
cmd = ['git', 'submodule',
|
271
|
+
verbose ? nil : '--quiet', 'update', '--reference', mirror.to_s, submodule_path.to_s].compact
|
272
|
+
fail_on_error(*cmd, quiet: !verbose, print_on_failure: print_git_errors,
|
273
|
+
chdir: File.join(abs_clone_path, pwd))
|
278
274
|
end
|
279
275
|
|
280
276
|
update_submodules(File.join(pwd, submodule_path), submodule_url)
|
@@ -350,19 +346,25 @@ module GitFastClone
|
|
350
346
|
quiet: !verbose, print_on_failure: print_git_errors)
|
351
347
|
end
|
352
348
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
end
|
349
|
+
cmd = ['git', 'remote', verbose ? '--verbose' : nil, 'update', '--prune'].compact
|
350
|
+
fail_on_error(*cmd, quiet: !verbose, print_on_failure: print_git_errors, chdir: mirror)
|
351
|
+
|
357
352
|
reference_updated[repo_name] = true
|
358
353
|
rescue RunnerExecutionRuntimeError => e
|
359
354
|
# To avoid corruption of the cache, if we failed to update or check out we remove
|
360
355
|
# the cache directory entirely. This may cause the current clone to fail, but if the
|
361
356
|
# underlying error from git is transient it will not affect future clones.
|
362
|
-
|
357
|
+
#
|
358
|
+
# The only exception to this is authentication failures, because they are transient,
|
359
|
+
# usually due to either a remote server outage or a local credentials config problem.
|
360
|
+
clear_cache(mirror, url) unless auth_error?(e.output)
|
363
361
|
raise e if fail_hard
|
364
362
|
end
|
365
363
|
|
364
|
+
def auth_error?(error)
|
365
|
+
error.to_s =~ /.*^fatal: Authentication failed/m
|
366
|
+
end
|
367
|
+
|
366
368
|
def retriable_error?(error)
|
367
369
|
error_strings = [
|
368
370
|
/^fatal: missing blob object/,
|
@@ -371,7 +373,8 @@ module GitFastClone
|
|
371
373
|
/^fatal: pack has \d+ unresolved delta/,
|
372
374
|
/^error: unable to read sha1 file of /,
|
373
375
|
/^fatal: did not receive expected object/,
|
374
|
-
/^fatal: unable to read tree [a-z0-9]+\n^warning: Clone succeeded, but checkout failed
|
376
|
+
/^fatal: unable to read tree [a-z0-9]+\n^warning: Clone succeeded, but checkout failed/,
|
377
|
+
/^fatal: Authentication failed/
|
375
378
|
]
|
376
379
|
error.to_s =~ /.*#{Regexp.union(error_strings)}/m
|
377
380
|
end
|
@@ -91,7 +91,6 @@ describe GitFastClone::Runner do
|
|
91
91
|
before(:each) do
|
92
92
|
allow(runner_execution_double).to receive(:fail_on_error) {}
|
93
93
|
allow(Dir).to receive(:pwd) { '/pwd' }
|
94
|
-
allow(Dir).to receive(:chdir).and_yield
|
95
94
|
allow(subject).to receive(:with_git_mirror).and_yield('/cache', 0)
|
96
95
|
expect(subject).to receive(:clear_clone_dest_if_needed).once {}
|
97
96
|
end
|
@@ -99,7 +98,7 @@ describe GitFastClone::Runner do
|
|
99
98
|
it 'should clone correctly' do
|
100
99
|
expect(subject).to receive(:fail_on_error).with(
|
101
100
|
'git', 'checkout', '--quiet', 'PH',
|
102
|
-
{
|
101
|
+
{ chdir: '/pwd/.', print_on_failure: false, quiet: true }
|
103
102
|
) { runner_execution_double }
|
104
103
|
expect(subject).to receive(:fail_on_error).with(
|
105
104
|
'git', 'clone', '--quiet', '--reference', '/cache', 'PH', '/pwd/.',
|
@@ -113,7 +112,7 @@ describe GitFastClone::Runner do
|
|
113
112
|
subject.verbose = true
|
114
113
|
expect(subject).to receive(:fail_on_error).with(
|
115
114
|
'git', 'checkout', '--quiet', 'PH',
|
116
|
-
{
|
115
|
+
{ chdir: '/pwd/.', print_on_failure: false, quiet: false }
|
117
116
|
) { runner_execution_double }
|
118
117
|
expect(subject).to receive(:fail_on_error).with(
|
119
118
|
'git', 'clone', '--verbose', '--reference', '/cache', 'PH', '/pwd/.',
|
@@ -309,7 +308,7 @@ describe GitFastClone::Runner do
|
|
309
308
|
|
310
309
|
describe '.store_updated_repo' do
|
311
310
|
context 'when fail_hard is true' do
|
312
|
-
it 'should raise a Runtime error and clear cache' do
|
311
|
+
it 'should raise a Runtime error and clear cache if there were no authentication errors' do
|
313
312
|
status = double('status')
|
314
313
|
allow(status).to receive(:exitstatus).and_return(1)
|
315
314
|
ex = RunnerExecution::RunnerExecutionRuntimeError.new(status, 'cmd')
|
@@ -319,6 +318,18 @@ describe GitFastClone::Runner do
|
|
319
318
|
subject.store_updated_repo(placeholder_arg, placeholder_arg, placeholder_arg, true)
|
320
319
|
end.to raise_error(ex)
|
321
320
|
end
|
321
|
+
|
322
|
+
it 'should raise a Runtime error and skip clearing the cache if there were authentication errors' do
|
323
|
+
status = double('status')
|
324
|
+
allow(status).to receive(:exitstatus).and_return(1)
|
325
|
+
ex = RunnerExecution::RunnerExecutionRuntimeError.new(status, 'cmd')
|
326
|
+
allow(ex).to receive(:output).and_return('fatal: Authentication failed')
|
327
|
+
allow(subject).to receive(:fail_on_error) { raise ex }
|
328
|
+
expect(FileUtils).to_not receive(:remove_entry_secure).with(placeholder_arg, force: true)
|
329
|
+
expect do
|
330
|
+
subject.store_updated_repo(placeholder_arg, placeholder_arg, placeholder_arg, true)
|
331
|
+
end.to raise_error(ex)
|
332
|
+
end
|
322
333
|
end
|
323
334
|
|
324
335
|
context 'when fail_hard is false' do
|
@@ -338,7 +349,6 @@ describe GitFastClone::Runner do
|
|
338
349
|
|
339
350
|
it 'should correctly update the hash' do
|
340
351
|
allow(subject).to receive(:fail_on_error)
|
341
|
-
allow(Dir).to receive(:chdir) {}
|
342
352
|
|
343
353
|
subject.reference_updated = placeholder_hash
|
344
354
|
subject.store_updated_repo(placeholder_arg, placeholder_arg, placeholder_arg, false)
|
@@ -389,7 +399,6 @@ describe GitFastClone::Runner do
|
|
389
399
|
expected_command = expected_commands.shift
|
390
400
|
expect(command).to eq(expected_command)
|
391
401
|
}
|
392
|
-
allow(Dir).to receive(:chdir).and_yield
|
393
402
|
|
394
403
|
allow(subject).to receive(:print_formatted_error) {}
|
395
404
|
allow(subject).to receive(:reference_repo_dir).and_return(test_reference_repo_dir)
|
@@ -404,7 +413,8 @@ describe GitFastClone::Runner do
|
|
404
413
|
[
|
405
414
|
['git', 'clone', verbose ? '--verbose' : '--quiet', '--mirror', test_url_valid,
|
406
415
|
test_reference_repo_dir],
|
407
|
-
['git', 'remote', verbose ? '--verbose' : nil, 'update',
|
416
|
+
['git', 'remote', verbose ? '--verbose' : nil, 'update',
|
417
|
+
'--prune'].compact
|
408
418
|
]
|
409
419
|
end
|
410
420
|
|
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.4.
|
4
|
+
version: 1.4.4
|
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: 2023-
|
12
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.4.
|
69
|
+
rubygems_version: 3.4.10
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: git-clone --recursive on steroids!
|