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 +4 -4
- data/lib/git-fastclone/version.rb +1 -1
- data/lib/git-fastclone.rb +11 -4
- data/spec/git_fastclone_runner_spec.rb +54 -10
- 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: 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
|
@@ -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
|
|
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
|
+
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:
|
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.
|
80
|
+
rubygems_version: 3.1.6
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: git-clone --recursive on steroids!
|