git-fastclone 1.5.0 → 1.5.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: 8b86bd9aa9bc5a377dd7d5b7b456eb0de1aee7ffd1e746642775d08042e9714f
4
- data.tar.gz: '08dff02e06757c022c7ee0fec4890261c3d3efbee76130f2c7f4e0c2cdd91361'
3
+ metadata.gz: 62066971856b4d6e34def960d0ec1214082d546f94a5ffe58b048eb5715511f0
4
+ data.tar.gz: d04c4ac8c866a011b3b6b279b3a9f2e719c6d284314086f91f4c73b189443f50
5
5
  SHA512:
6
- metadata.gz: ce36dfc95ed1d5621fc32df5721d1b796e1cdbb58c11952351dd124bf14a784bef8624e23bde74be3a3c848fff320201639b0e7737be44c8860860a0fb99a019
7
- data.tar.gz: 77a296e5b3c6ea817fef4c0ca6df39c4f33e8f35626fd896d4f41ff9c201bf8de15c57a0543e7a8aac4cf63f7de352a00b01844c964657fb20192abbce3790a4
6
+ metadata.gz: d807b912fd16fc82e3ce6ea2a3d568f37d1a946efdb750e7279baafa2a0c8206b2b6b298165321a0dd6306a975aacc873f0863c7ff18259b0b0126dd3c83f299
7
+ data.tar.gz: 0dde85446cad33944b3e1e61327b4656c435312fd6ef169b2b82fc4506d6e6bcedebdb0c808b5bdb52e7b0249472c2f033fa86647cadb6626dbcc953efaa6645
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Version string for git-fastclone
4
4
  module GitFastCloneVersion
5
- VERSION = '1.5.0'
5
+ VERSION = '1.5.1'
6
6
  end
data/lib/git-fastclone.rb CHANGED
@@ -162,14 +162,15 @@ module GitFastClone
162
162
  options[:config] = config
163
163
  end
164
164
 
165
- opts.on('--lock-timeout N', 'Timeout in seconds to acquire a lock on any reference repo.
166
- Default is 0 which waits indefinitely.') do |timeout_secs|
165
+ opts.on('--lock-timeout N', 'Timeout in seconds to acquire a lock on any reference repo.',
166
+ 'Default is 0 which waits indefinitely.') do |timeout_secs|
167
167
  self.flock_timeout_secs = timeout_secs.to_i
168
168
  end
169
169
 
170
- opts.on('--pre-clone-hook command',
171
- 'An optional command that should be invoked before cloning mirror repo') do |command|
172
- options[:pre_clone_hook] = command
170
+ opts.on('--pre-clone-hook script_file',
171
+ 'An optional file that should be invoked before cloning mirror repo',
172
+ 'No-op when a file is missing') do |script_file|
173
+ options[:pre_clone_hook] = script_file
173
174
  end
174
175
  end.parse!
175
176
  end
@@ -452,7 +453,13 @@ module GitFastClone
452
453
  private def trigger_pre_clone_hook_if_needed(url, mirror, attempt_number)
453
454
  return if Dir.exist?(mirror) || !options.include?(:pre_clone_hook)
454
455
 
455
- popen2e_wrapper(options[:pre_clone_hook], url.to_s, mirror.to_s, attempt_number.to_s, quiet: !verbose)
456
+ hook_command = options[:pre_clone_hook]
457
+ unless File.exist?(File.expand_path(hook_command))
458
+ puts 'pre_clone_hook script is missing' if verbose
459
+ return
460
+ end
461
+
462
+ popen2e_wrapper(hook_command, url.to_s, mirror.to_s, attempt_number.to_s, quiet: !verbose)
456
463
  end
457
464
  end
458
465
  end
@@ -146,11 +146,13 @@ describe GitFastClone::Runner do
146
146
  end
147
147
  end
148
148
 
149
- context 'with pre-clone-hook errors' do
149
+ context 'with pre-clone-hook' do
150
150
  let(:pre_clone_hook) { '/some/command' }
151
151
  before(:each) do
152
152
  subject.options[:pre_clone_hook] = pre_clone_hook
153
153
  subject.reference_dir = placeholder_arg
154
+ allow(File).to receive(:exist?).and_call_original
155
+ allow(File).to receive(:exist?).with(pre_clone_hook).and_return(true)
154
156
  allow(subject).to receive(:with_git_mirror).and_call_original
155
157
  allow(subject).to receive(:with_reference_repo_lock) do |_url, &block|
156
158
  block.call
@@ -192,6 +194,22 @@ describe GitFastClone::Runner do
192
194
 
193
195
  subject.clone(placeholder_arg, nil, '.', 'config')
194
196
  end
197
+
198
+ context 'non-existing script' do
199
+ before(:each) do
200
+ allow(File).to receive(:exist?).with(pre_clone_hook).and_return(false)
201
+ end
202
+
203
+ it 'does not invoke hook command' do
204
+ allow(subject).to receive(:fail_on_error)
205
+ expect(subject).not_to receive(:popen2e_wrapper).with(
206
+ pre_clone_hook, 'PH', 'PH/PH', '0',
207
+ { quiet: true }
208
+ )
209
+
210
+ subject.clone(placeholder_arg, nil, '.', 'config')
211
+ end
212
+ end
195
213
  end
196
214
  end
197
215
 
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.5.0
4
+ version: 1.5.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: 2024-02-23 00:00:00.000000000 Z
12
+ date: 2024-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize