git-fastclone 1.4.0 → 1.4.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: ed5f3f84cbab65351479f22b659b912521699f542c898010527f25b7c3786c84
4
- data.tar.gz: 5f02716656bf0962d9a808ae368078f0e151e6bdfd3abba5b25503504f64194b
3
+ metadata.gz: 7e915bc1276ac42ac35559122dc1c12f4a04778032ec4510fe96a64b37fc4a7a
4
+ data.tar.gz: 9fcb6e4a441106da6b09f2d4b39cf0e740942ae99de051712fba27656d962f04
5
5
  SHA512:
6
- metadata.gz: a9219567c52c31d5219027adb6227c88970dd839fa8dd2f50258fc205adc3e4f9372d44d6f734242849865d7885f6b8f5a3fadfef05f77c88e24d8d85016a849
7
- data.tar.gz: c136b5240dfc87480457c924772944282f518f8c77d49473f41724449ae0566d8cc5476e6f698aa86de2b18f1f77a8995d0f5f3e8778546630e390d6ed2d2530
6
+ metadata.gz: fc52b41c18799ec2154000bc7762c8301ed50f28d2eb252e4adcdc82ff36cdc6e3fa772d85db4d52ea95782ea16e02ea0460f1488b5ce95a745ee8a451511a3d
7
+ data.tar.gz: f86877adef196e5416e69aac06c7129bfaf22a21a566a5afe05e4780da60cdc3f0e2379e81d1bc0b4e8bd129d18a893f925dbd7096a4057ef428f085a964b2f2
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Version string for git-fastclone
4
4
  module GitFastCloneVersion
5
- VERSION = '1.4.0'
5
+ VERSION = '1.4.1'
6
6
  end
data/lib/git-fastclone.rb CHANGED
@@ -212,13 +212,13 @@ module GitFastClone
212
212
  clone_commands = ['git', 'clone', verbose ? '--verbose' : '--quiet']
213
213
  clone_commands << '--reference' << mirror.to_s << url.to_s << clone_dest
214
214
  clone_commands << '--config' << config.to_s unless config.nil?
215
- fail_pipe_on_error(clone_commands, quiet: !verbose)
215
+ fail_on_error(*clone_commands, quiet: !verbose)
216
216
  end
217
217
 
218
218
  # Only checkout if we're changing branches to a non-default branch
219
219
  if rev
220
220
  Dir.chdir(File.join(abs_clone_path, src_dir)) do
221
- fail_pipe_on_error(['git', 'checkout', '--quiet', rev.to_s], quiet: !verbose)
221
+ fail_on_error('git', 'checkout', '--quiet', rev.to_s, quiet: !verbose)
222
222
  end
223
223
  end
224
224
 
@@ -261,10 +261,9 @@ module GitFastClone
261
261
  threads << Thread.new do
262
262
  with_git_mirror(submodule_url) do |mirror, _|
263
263
  Dir.chdir(File.join(abs_clone_path, pwd).to_s) do
264
- fail_pipe_on_error(
265
- ['git', 'submodule', verbose ? nil : '--quiet', 'update', '--reference', mirror.to_s,
266
- submodule_path.to_s].compact, quiet: !verbose
267
- )
264
+ cmd = ['git', 'submodule', verbose ? nil : '--quiet', 'update', '--reference', mirror.to_s,
265
+ submodule_path.to_s].compact
266
+ fail_on_error(*cmd, quiet: !verbose)
268
267
  end
269
268
  end
270
269
 
@@ -337,21 +336,13 @@ module GitFastClone
337
336
  # that this repo has been updated on this run of fastclone
338
337
  def store_updated_repo(url, mirror, repo_name, fail_hard)
339
338
  unless Dir.exist?(mirror)
340
- fail_pipe_on_error(
341
- ['git', 'clone', verbose ? '--verbose' : '--quiet', '--mirror', url.to_s,
342
- mirror.to_s], quiet: !verbose
343
- )
339
+ fail_on_error('git', 'clone', verbose ? '--verbose' : '--quiet', '--mirror', url.to_s, mirror.to_s,
340
+ quiet: !verbose)
344
341
  end
345
342
 
346
343
  Dir.chdir(mirror) do
347
344
  cmd = ['git', 'remote', verbose ? '--verbose' : nil, 'update', '--prune'].compact
348
- if verbose
349
- fail_pipe_on_error(cmd, quiet: !verbose)
350
- else
351
- # Because above operation might spit out a lot to stderr, we use this to swallow them
352
- # and only display if the operation return non 0 exit code
353
- fail_on_error(*cmd, quiet: !verbose)
354
- end
345
+ fail_on_error(*cmd, quiet: !verbose)
355
346
  end
356
347
  reference_updated[repo_name] = true
357
348
  rescue RunnerExecutionRuntimeError => e
@@ -20,34 +20,6 @@ module RunnerExecution
20
20
  end
21
21
  end
22
22
 
23
- # Wrapper around open3.pipeline_r which fails on error.
24
- # and stops users from invoking the shell by accident.
25
- def fail_pipe_on_error(*cmd_list, quiet: false, **opts)
26
- print_command('Running Pipeline:', cmd_list) unless quiet
27
-
28
- env = opts.delete(:env) { {} }
29
- raise ArgumentError, "The :env option must be a hash, not #{env.inspect}" unless env.is_a?(Hash)
30
-
31
- cmd_list.map! { |cmd| shell_safe(cmd).unshift(env) }
32
-
33
- output, *status_list = Open3.pipeline_r(*cmd_list, opts) do |out, wait_threads|
34
- out_reader = Thread.new do
35
- if quiet
36
- output = out.read
37
- else
38
- # Output from pipeline should go to stdout and also get returned for
39
- # processing if necessary.
40
- output = tee(out, STDOUT)
41
- end
42
- out.close
43
- output
44
- end
45
- [out_reader.value] + wait_threads.map(&:value)
46
- end
47
- exit_on_status(output, cmd_list, status_list, quiet: quiet)
48
- end
49
- module_function :fail_pipe_on_error
50
-
51
23
  # Runs a command that fails on error.
52
24
  # Uses popen2e wrapper. Handles bad statuses with potential for retries.
53
25
  def fail_on_error(*cmd, stdin_data: nil, binmode: false, quiet: false, **opts)
@@ -89,7 +89,7 @@ describe GitFastClone::Runner do
89
89
  describe '.clone' do
90
90
  let(:runner_execution_double) { double('runner_execution') }
91
91
  before(:each) do
92
- allow(runner_execution_double).to receive(:fail_pipe_on_error) {}
92
+ allow(runner_execution_double).to receive(:fail_on_error) {}
93
93
  allow(Dir).to receive(:pwd) { '/pwd' }
94
94
  allow(Dir).to receive(:chdir).and_yield
95
95
  allow(subject).to receive(:with_git_mirror).and_yield('/cache', 0)
@@ -97,12 +97,12 @@ describe GitFastClone::Runner do
97
97
  end
98
98
 
99
99
  it 'should clone correctly' do
100
- expect(subject).to receive(:fail_pipe_on_error).with(
101
- ['git', 'checkout', '--quiet', 'PH'],
100
+ expect(subject).to receive(:fail_on_error).with(
101
+ 'git', 'checkout', '--quiet', 'PH',
102
102
  { quiet: true }
103
103
  ) { runner_execution_double }
104
- expect(subject).to receive(:fail_pipe_on_error).with(
105
- ['git', 'clone', '--quiet', '--reference', '/cache', 'PH', '/pwd/.'],
104
+ expect(subject).to receive(:fail_on_error).with(
105
+ 'git', 'clone', '--quiet', '--reference', '/cache', 'PH', '/pwd/.',
106
106
  { quiet: true }
107
107
  ) { runner_execution_double }
108
108
 
@@ -111,12 +111,12 @@ describe GitFastClone::Runner do
111
111
 
112
112
  it 'should clone correctly with verbose mode on' do
113
113
  subject.verbose = true
114
- expect(subject).to receive(:fail_pipe_on_error).with(
115
- ['git', 'checkout', '--quiet', 'PH'],
114
+ expect(subject).to receive(:fail_on_error).with(
115
+ 'git', 'checkout', '--quiet', 'PH',
116
116
  { quiet: false }
117
117
  ) { runner_execution_double }
118
- expect(subject).to receive(:fail_pipe_on_error).with(
119
- ['git', 'clone', '--verbose', '--reference', '/cache', 'PH', '/pwd/.'],
118
+ expect(subject).to receive(:fail_on_error).with(
119
+ 'git', 'clone', '--verbose', '--reference', '/cache', 'PH', '/pwd/.',
120
120
  { quiet: false }
121
121
  ) { runner_execution_double }
122
122
 
@@ -124,8 +124,8 @@ describe GitFastClone::Runner do
124
124
  end
125
125
 
126
126
  it 'should clone correctly with custom configs' do
127
- expect(subject).to receive(:fail_pipe_on_error).with(
128
- ['git', 'clone', '--quiet', '--reference', '/cache', 'PH', '/pwd/.', '--config', 'config'],
127
+ expect(subject).to receive(:fail_on_error).with(
128
+ 'git', 'clone', '--quiet', '--reference', '/cache', 'PH', '/pwd/.', '--config', 'config',
129
129
  { quiet: true }
130
130
  ) { runner_execution_double }
131
131
 
@@ -298,7 +298,7 @@ describe GitFastClone::Runner do
298
298
  status = double('status')
299
299
  allow(status).to receive(:exitstatus).and_return(1)
300
300
  ex = RunnerExecution::RunnerExecutionRuntimeError.new(status, 'cmd')
301
- allow(subject).to receive(:fail_pipe_on_error) { raise ex }
301
+ allow(subject).to receive(:fail_on_error) { raise ex }
302
302
  expect(FileUtils).to receive(:remove_entry_secure).with(placeholder_arg, force: true)
303
303
  expect do
304
304
  subject.store_updated_repo(placeholder_arg, placeholder_arg, placeholder_arg, true)
@@ -311,7 +311,7 @@ describe GitFastClone::Runner do
311
311
  status = double('status')
312
312
  allow(status).to receive(:exitstatus).and_return(1)
313
313
  ex = RunnerExecution::RunnerExecutionRuntimeError.new(status, 'cmd')
314
- allow(subject).to receive(:fail_pipe_on_error) { raise ex }
314
+ allow(subject).to receive(:fail_on_error) { raise ex }
315
315
  expect(FileUtils).to receive(:remove_entry_secure).with(placeholder_arg, force: true)
316
316
  expect do
317
317
  subject.store_updated_repo(placeholder_arg, placeholder_arg, placeholder_arg, false)
@@ -322,7 +322,7 @@ describe GitFastClone::Runner do
322
322
  let(:placeholder_hash) { {} }
323
323
 
324
324
  it 'should correctly update the hash' do
325
- allow(subject).to receive(:fail_pipe_on_error)
325
+ allow(subject).to receive(:fail_on_error)
326
326
  allow(Dir).to receive(:chdir) {}
327
327
 
328
328
  subject.reference_updated = placeholder_hash
@@ -367,12 +367,6 @@ describe GitFastClone::Runner do
367
367
  let(:expected_commands) { [] }
368
368
 
369
369
  before(:each) do
370
- allow(subject).to receive(:fail_pipe_on_error) { |*params|
371
- command = params[0]
372
- expect(expected_commands.length).to be > 0
373
- expected_command = expected_commands.shift
374
- expect(command).to eq(expected_command)
375
- }
376
370
  allow(subject).to receive(:fail_on_error) { |*params|
377
371
  # last one is an argument `quiet:`
378
372
  command = params.first(params.size - 1)
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.0
4
+ version: 1.4.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: 2023-03-13 00:00:00.000000000 Z
12
+ date: 2023-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize