git-fastclone 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/git-fastclone/version.rb +1 -1
- data/lib/git-fastclone.rb +13 -5
- data/spec/git_fastclone_runner_spec.rb +84 -11
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e6bcf21a8d3b9c1b30b93efc17487fa8dfa0c319b8636efc1f96a430e27c876
|
4
|
+
data.tar.gz: 7720184507344bc94ad63e45b135e0948aab6776d371867159a4cd84dcfd2a0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e48d37e5162a8288da830232476fb12ba7b8bb01c0ef0834a8eb372a224c0a2f8430d10002a9c54c1ec7fc7713db384ef32d0da9f1707366663bbe10e9ff04
|
7
|
+
data.tar.gz: 1f74af758cfbd3f47f98f6d4fc1a47e24bf574f9e7b58116b9aa3f6186ab334e66c66e413416641b7ce6494b3099b45158142fbd88b4c1bb3a0bb48a86c9b912
|
data/lib/git-fastclone.rb
CHANGED
@@ -121,7 +121,7 @@ module GitFastClone
|
|
121
121
|
puts "Cloning #{path_from_git_url(url)} to #{File.join(abs_clone_path, path)}"
|
122
122
|
Terrapin::CommandLine.environment['GIT_ALLOW_PROTOCOL'] =
|
123
123
|
ENV['GIT_ALLOW_PROTOCOL'] || DEFAULT_GIT_ALLOW_PROTOCOL
|
124
|
-
clone(url, options[:branch], path)
|
124
|
+
clone(url, options[:branch], path, options[:config])
|
125
125
|
end
|
126
126
|
|
127
127
|
def parse_options
|
@@ -148,6 +148,10 @@ module GitFastClone
|
|
148
148
|
self.color = true
|
149
149
|
end
|
150
150
|
|
151
|
+
opts.on('--config CONFIG', 'Git config applied to the cloned repo') do |config|
|
152
|
+
options[:config] = config
|
153
|
+
end
|
154
|
+
|
151
155
|
opts.on('--lock-timeout N', 'Timeout in seconds to acquire a lock on any reference repo.
|
152
156
|
Default is 0 which waits indefinitely.') do |timeout_secs|
|
153
157
|
self.flock_timeout_secs = timeout_secs
|
@@ -187,14 +191,17 @@ module GitFastClone
|
|
187
191
|
|
188
192
|
# Checkout to SOURCE_DIR. Update all submodules recursively. Use reference
|
189
193
|
# repos everywhere for speed.
|
190
|
-
def clone(url, rev, src_dir)
|
194
|
+
def clone(url, rev, src_dir, config)
|
191
195
|
initial_time = Time.now
|
192
196
|
|
193
197
|
with_git_mirror(url) do |mirror|
|
194
|
-
|
198
|
+
clone_command = '--quiet --reference :mirror :url :path'
|
199
|
+
clone_command += ' --config :config' unless config.nil?
|
200
|
+
Terrapin::CommandLine.new('git clone', clone_command)
|
195
201
|
.run(mirror: mirror.to_s,
|
196
202
|
url: url.to_s,
|
197
|
-
path: File.join(abs_clone_path, src_dir).to_s
|
203
|
+
path: File.join(abs_clone_path, src_dir).to_s,
|
204
|
+
config: config.to_s)
|
198
205
|
end
|
199
206
|
|
200
207
|
# Only checkout if we're changing branches to a non-default branch
|
@@ -358,7 +365,8 @@ module GitFastClone
|
|
358
365
|
/fatal: packed object [a-z0-9]+ \(stored in .*?\) is corrupt/,
|
359
366
|
/fatal: pack has \d+ unresolved delta/,
|
360
367
|
'error: unable to read sha1 file of ',
|
361
|
-
'fatal: did not receive expected object'
|
368
|
+
'fatal: did not receive expected object',
|
369
|
+
/^fatal: unable to read tree [a-z0-9]+\n^warning: Clone succeeded, but checkout failed/
|
362
370
|
]
|
363
371
|
if e.to_s =~ /^STDERR:\n.+^#{Regexp.union(error_strings)}/m
|
364
372
|
# To avoid corruption of the cache, if we failed to update or check out we remove
|
@@ -56,11 +56,22 @@ describe GitFastClone::Runner do
|
|
56
56
|
let(:options) { { branch: placeholder_arg } }
|
57
57
|
|
58
58
|
it 'should run with the correct args' do
|
59
|
-
allow(subject).to receive(:parse_inputs) { [placeholder_arg, placeholder_arg, options] }
|
60
|
-
expect(subject).to receive(:clone).with(placeholder_arg, placeholder_arg, placeholder_arg)
|
59
|
+
allow(subject).to receive(:parse_inputs) { [placeholder_arg, placeholder_arg, options, nil] }
|
60
|
+
expect(subject).to receive(:clone).with(placeholder_arg, placeholder_arg, placeholder_arg, nil)
|
61
61
|
|
62
62
|
subject.run
|
63
63
|
end
|
64
|
+
|
65
|
+
describe 'with custom configs' do
|
66
|
+
let(:options) { { branch: placeholder_arg, config: 'conf' } }
|
67
|
+
|
68
|
+
it 'should clone correctly' do
|
69
|
+
allow(subject).to receive(:parse_inputs) { [placeholder_arg, placeholder_arg, options, 'conf'] }
|
70
|
+
expect(subject).to receive(:clone).with(placeholder_arg, placeholder_arg, placeholder_arg, 'conf')
|
71
|
+
|
72
|
+
subject.run
|
73
|
+
end
|
74
|
+
end
|
64
75
|
end
|
65
76
|
|
66
77
|
describe '.parse_inputs' do
|
@@ -74,17 +85,50 @@ describe GitFastClone::Runner do
|
|
74
85
|
end
|
75
86
|
|
76
87
|
describe '.clone' do
|
77
|
-
|
78
|
-
|
79
|
-
allow(subject).to receive(:with_git_mirror) {}
|
88
|
+
let(:terrapin_commandline_double) { double('new_terrapin_commandline') }
|
89
|
+
before(:each) do
|
80
90
|
allow(terrapin_commandline_double).to receive(:run) {}
|
81
|
-
allow(Terrapin::CommandLine).to receive(:new) { terrapin_commandline_double }
|
82
|
-
|
83
91
|
expect(Time).to receive(:now).twice { 0 }
|
84
|
-
|
85
|
-
|
92
|
+
allow(Dir).to receive(:pwd) { '/pwd' }
|
93
|
+
allow(Dir).to receive(:chdir).and_yield
|
94
|
+
allow(subject).to receive(:with_git_mirror).and_yield('/cache')
|
95
|
+
end
|
86
96
|
|
87
|
-
|
97
|
+
it 'should clone correctly' do
|
98
|
+
expect(Terrapin::CommandLine).to receive(:new).with(
|
99
|
+
'git clone',
|
100
|
+
'--quiet --reference :mirror :url :path'
|
101
|
+
) { terrapin_commandline_double }
|
102
|
+
expect(Terrapin::CommandLine).to receive(:new).with(
|
103
|
+
'git checkout',
|
104
|
+
'--quiet :rev'
|
105
|
+
) { terrapin_commandline_double }
|
106
|
+
expect(terrapin_commandline_double).to receive(:run).with(
|
107
|
+
mirror: '/cache',
|
108
|
+
url: placeholder_arg,
|
109
|
+
path: '/pwd/.',
|
110
|
+
config: ''
|
111
|
+
)
|
112
|
+
expect(terrapin_commandline_double).to receive(:run).with(rev: placeholder_arg)
|
113
|
+
|
114
|
+
subject.clone(placeholder_arg, placeholder_arg, '.', nil)
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'with custom configs' do
|
118
|
+
it 'should clone correctly' do
|
119
|
+
expect(Terrapin::CommandLine).to receive(:new).with(
|
120
|
+
'git clone',
|
121
|
+
'--quiet --reference :mirror :url :path --config :config'
|
122
|
+
) { terrapin_commandline_double }
|
123
|
+
expect(terrapin_commandline_double).to receive(:run).with(
|
124
|
+
mirror: '/cache',
|
125
|
+
url: placeholder_arg,
|
126
|
+
path: '/pwd/.',
|
127
|
+
config: 'config'
|
128
|
+
)
|
129
|
+
|
130
|
+
subject.clone(placeholder_arg, nil, '.', 'config')
|
131
|
+
end
|
88
132
|
end
|
89
133
|
end
|
90
134
|
|
@@ -306,7 +350,7 @@ describe GitFastClone::Runner do
|
|
306
350
|
expect(yielded).to eq([test_url_valid])
|
307
351
|
end
|
308
352
|
|
309
|
-
it 'should retry when the clone succeeds but checkout fails' do
|
353
|
+
it 'should retry when the clone succeeds but checkout fails with corrupt packed object' do
|
310
354
|
allow(subject).to receive(:update_reference_repo) {}
|
311
355
|
expect(subject).to receive(:reference_repo_dir)
|
312
356
|
expect(subject).to receive(:reference_repo_lock_file).and_return(lockfile)
|
@@ -333,6 +377,35 @@ describe GitFastClone::Runner do
|
|
333
377
|
expect(yielded).to eq([test_url_valid])
|
334
378
|
end
|
335
379
|
|
380
|
+
it 'should retry when the clone succeeds but checkout fails with unable to read tree' do
|
381
|
+
allow(subject).to receive(:update_reference_repo) {}
|
382
|
+
expect(subject).to receive(:reference_repo_dir)
|
383
|
+
expect(subject).to receive(:reference_repo_lock_file).and_return(lockfile)
|
384
|
+
|
385
|
+
responses = [
|
386
|
+
lambda { |_url|
|
387
|
+
raise Terrapin::ExitStatusError, <<-ERROR.gsub(/^ {12}/, '')
|
388
|
+
STDOUT:
|
389
|
+
|
390
|
+
STDERR:
|
391
|
+
|
392
|
+
error: Could not read 92cf57b8f07df010ab5f607b109c325e30e46235
|
393
|
+
fatal: unable to read tree 0c32c0521d3b0bfb4e74e4a39b97a84d1a3bb9a1
|
394
|
+
warning: Clone succeeded, but checkout failed.
|
395
|
+
You can inspect what was checked out with 'git status'
|
396
|
+
and retry with 'git restore --source=HEAD :/'
|
397
|
+
ERROR
|
398
|
+
},
|
399
|
+
->(url) { url }
|
400
|
+
]
|
401
|
+
subject.with_git_mirror(test_url_valid) do
|
402
|
+
yielded << responses.shift.call(test_url_valid)
|
403
|
+
end
|
404
|
+
|
405
|
+
expect(responses).to be_empty
|
406
|
+
expect(yielded).to eq([test_url_valid])
|
407
|
+
end
|
408
|
+
|
336
409
|
it 'should retry when one delta is missing' do
|
337
410
|
allow(subject).to receive(:update_reference_repo) {}
|
338
411
|
expect(subject).to receive(:reference_repo_dir)
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-fastclone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Tauraso
|
8
8
|
- James Chang
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -62,7 +62,7 @@ homepage: http://square.github.io/git-fastclone/
|
|
62
62
|
licenses:
|
63
63
|
- Apache
|
64
64
|
metadata: {}
|
65
|
-
post_install_message:
|
65
|
+
post_install_message:
|
66
66
|
rdoc_options: []
|
67
67
|
require_paths:
|
68
68
|
- lib
|
@@ -77,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
-
signing_key:
|
80
|
+
rubygems_version: 3.1.6
|
81
|
+
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: git-clone --recursive on steroids!
|
84
84
|
test_files:
|