git-fastclone 1.2.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22f5537cbc1297198ea1aa106a305ef5ad9526dc24fc9a39048c6889e6d441b4
4
- data.tar.gz: 0f1f38ba2756185c3c02b7a5ec3cf40c01e4498e743388f41991ca1d817793de
3
+ metadata.gz: 3e6bcf21a8d3b9c1b30b93efc17487fa8dfa0c319b8636efc1f96a430e27c876
4
+ data.tar.gz: 7720184507344bc94ad63e45b135e0948aab6776d371867159a4cd84dcfd2a0d
5
5
  SHA512:
6
- metadata.gz: 22634dabfc0c4d91682dc7db8d9e18e6cdc4a6d6db079a66c5e498ccc6ed70c8bcb7ccd24657b91e5142d0fe8be0f34169223d1d70cb1262ed3c6d88e3ec0e83
7
- data.tar.gz: 8dd73fac0eb7eec9b8e8ead616a48549860722982b756b950ad020cd295da4dffeaf4b89b7dad3c88f2dc4b82119a40172a499441924bbcf2885e280313850eb
6
+ metadata.gz: 13e48d37e5162a8288da830232476fb12ba7b8bb01c0ef0834a8eb372a224c0a2f8430d10002a9c54c1ec7fc7713db384ef32d0da9f1707366663bbe10e9ff04
7
+ data.tar.gz: 1f74af758cfbd3f47f98f6d4fc1a47e24bf574f9e7b58116b9aa3f6186ab334e66c66e413416641b7ce6494b3099b45158142fbd88b4c1bb3a0bb48a86c9b912
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Version string for git-fastclone
4
4
  module GitFastCloneVersion
5
- VERSION = '1.2.7'.freeze
5
+ VERSION = '1.3.0'.freeze
6
6
  end
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
- Terrapin::CommandLine.new('git clone', '--quiet --reference :mirror :url :path')
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
@@ -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
- it 'should clone correctly' do
78
- terrapin_commandline_double = double('new_terrapin_commandline')
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
- expect(Terrapin::CommandLine).to receive(:new)
85
- expect(terrapin_commandline_double).to receive(:run)
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
- subject.clone(placeholder_arg, placeholder_arg, '.')
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
 
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.7
4
+ version: 1.3.0
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: 2021-02-26 00:00:00.000000000 Z
12
+ date: 2022-12-03 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.1
80
+ rubygems_version: 3.1.6
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: git-clone --recursive on steroids!