git-fastclone 1.1.2 → 1.2.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
- SHA1:
3
- metadata.gz: ebc92dd7541a4acc3c73355da48b66541373b29a
4
- data.tar.gz: 99c1ebf5cd8df06cfd5d487b04f764301b75ee5e
2
+ SHA256:
3
+ metadata.gz: 9383bab9258efe9c7f106182b92ffbe0a66031a799f61313286c5525353a6676
4
+ data.tar.gz: f8611d4f1c8afc78b1fb0a65af35e386b5c7ecdfe9b8bafe36c391670e2f4622
5
5
  SHA512:
6
- metadata.gz: 66e543070bdd86fff06f6a18f3e1d55c94319a1bf0dfe73481c36942b56294532fdde406f2bca65c1b9c78a9ee9992ad27e2efcedc5b79be652b78bcc2c94207
7
- data.tar.gz: 662e46428e556027005781eef6896ee6c1525726257aabfcd6d3661df20f30df378bfd61ceb37a65a6c68fc4ea4874e371ad066d797655250ed34d2e45bb1fe8
6
+ metadata.gz: 4182af8e5b3e978167466329df3fceb3e0b14808e71425d121d447bb84b0d37490eae4cad9a8c1c8b05f4fecdc1bc0e9da2a5743fd6d761bd6c33e66d2fa5dd7
7
+ data.tar.gz: 42fb710ef3ec9ab6eae8c7f176ea4f4dffca799326b590130c4c8fc8649430f9f367ffa9edbbebeb7db89ec272620750c5368d681f57dcb05f79e4be64156fca
data/README.md CHANGED
@@ -75,7 +75,7 @@ Before accepting any pull requests, we need you to sign an [Individual Contribut
75
75
 
76
76
  Acknowledgements
77
77
  ----------------
78
- [thoughtbot/cocaine][3] - jyurek and collaborators
78
+ [thoughtbot/terrapin][3] - jyurek and collaborators
79
79
 
80
80
  [robolson][4]
81
81
 
@@ -104,7 +104,7 @@ License
104
104
 
105
105
  [1]: https://corner.squareup.com/2015/11/fastclone.html
106
106
  [2]: https://docs.google.com/a/squareup.com/forms/d/13WR8m5uZ2nAkJH41k7GdVBXAAbzDk00vxtEYjd6Imzg/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
107
- [3]: https://github.com/thoughtbot/cocaine
107
+ [3]: https://github.com/thoughtbot/terrapin
108
108
  [4]: https://github.com/robolson
109
109
  [5]: https://github.com/ianchesal
110
110
  [6]: https://github.com/mtauraso
data/Rakefile CHANGED
@@ -1,11 +1,16 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/setup'
4
4
 
5
- task default: %w(spec rubocop)
5
+ task default: %w[spec]
6
6
 
7
7
  require 'rspec/core/rake_task'
8
8
  RSpec::Core::RakeTask.new
9
9
 
10
- require 'rubocop/rake_task'
11
- RuboCop::RakeTask.new
10
+ begin
11
+ require 'rubocop/rake_task'
12
+ RuboCop::RakeTask.new
13
+ task default: :rubocop
14
+ rescue LoadError => e
15
+ raise unless e.path == 'rubocop/rake_task'
16
+ end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Copyright 2015 Square Inc.
4
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2015 Square Inc.
2
4
 
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +17,7 @@
15
17
  require 'optparse'
16
18
  require 'fileutils'
17
19
  require 'logger'
18
- require 'cocaine'
20
+ require 'terrapin'
19
21
  require 'timeout'
20
22
 
21
23
  # Contains helper module UrlHelper and execution class GitFastClone::Runner
@@ -53,7 +55,7 @@ module GitFastClone
53
55
 
54
56
  def reference_repo_lock_file(url, reference_dir, using_local_repo)
55
57
  lock_file_name = "#{reference_repo_dir(url, reference_dir, using_local_repo)}:lock"
56
- File.open(lock_file_name, File::RDWR | File::CREAT, 0644)
58
+ File.open(lock_file_name, File::RDWR | File::CREAT, 0o644)
57
59
  end
58
60
  module_function :reference_repo_lock_file
59
61
  end
@@ -117,7 +119,7 @@ module GitFastClone
117
119
  end
118
120
 
119
121
  puts "Cloning #{path_from_git_url(url)} to #{File.join(abs_clone_path, path)}"
120
- Cocaine::CommandLine.environment['GIT_ALLOW_PROTOCOL'] =
122
+ Terrapin::CommandLine.environment['GIT_ALLOW_PROTOCOL'] =
121
123
  ENV['GIT_ALLOW_PROTOCOL'] || DEFAULT_GIT_ALLOW_PROTOCOL
122
124
  clone(url, options[:branch], path)
123
125
  end
@@ -139,7 +141,7 @@ module GitFastClone
139
141
  logger.formatter = proc do |_severity, _datetime, _progname, msg|
140
142
  "#{msg}\n"
141
143
  end
142
- Cocaine::CommandLine.logger = logger
144
+ Terrapin::CommandLine.logger = logger
143
145
  end
144
146
 
145
147
  opts.on('-c', '--color', 'Display colored output') do
@@ -172,8 +174,9 @@ module GitFastClone
172
174
 
173
175
  if Dir.exist?(path)
174
176
  msg = "Clone destination #{File.join(abs_clone_path, path)} already exists!"
175
- fail msg.red if color
176
- fail msg
177
+ raise msg.red if color
178
+
179
+ raise msg
177
180
  end
178
181
 
179
182
  self.reference_dir = ENV['REFERENCE_REPO_DIR'] || DEFAULT_REFERENCE_REPO_DIR
@@ -188,16 +191,16 @@ module GitFastClone
188
191
  initial_time = Time.now
189
192
 
190
193
  with_git_mirror(url) do |mirror|
191
- Cocaine::CommandLine.new('git clone', '--quiet --reference :mirror :url :path')
192
- .run(mirror: mirror.to_s,
193
- url: url.to_s,
194
- path: File.join(abs_clone_path, src_dir).to_s)
194
+ Terrapin::CommandLine.new('git clone', '--quiet --reference :mirror :url :path')
195
+ .run(mirror: mirror.to_s,
196
+ url: url.to_s,
197
+ path: File.join(abs_clone_path, src_dir).to_s)
195
198
  end
196
199
 
197
200
  # Only checkout if we're changing branches to a non-default branch
198
201
  if rev
199
202
  Dir.chdir(File.join(abs_clone_path, src_dir)) do
200
- Cocaine::CommandLine.new('git checkout', '--quiet :rev').run(rev: rev.to_s)
203
+ Terrapin::CommandLine.new('git checkout', '--quiet :rev').run(rev: rev.to_s)
201
204
  end
202
205
  end
203
206
 
@@ -221,8 +224,8 @@ module GitFastClone
221
224
  threads = []
222
225
  submodule_url_list = []
223
226
 
224
- Cocaine::CommandLine.new('cd', ':path; git submodule init 2>&1')
225
- .run(path: File.join(abs_clone_path, pwd)).split("\n").each do |line|
227
+ Terrapin::CommandLine.new('cd', ':path; git submodule init 2>&1')
228
+ .run(path: File.join(abs_clone_path, pwd)).split("\n").each do |line|
226
229
  submodule_path, submodule_url = parse_update_info(line)
227
230
  submodule_url_list << submodule_url
228
231
 
@@ -236,10 +239,10 @@ module GitFastClone
236
239
  def thread_update_submodule(submodule_url, submodule_path, threads, pwd)
237
240
  threads << Thread.new do
238
241
  with_git_mirror(submodule_url) do |mirror|
239
- Cocaine::CommandLine.new('cd', ':dir; git submodule update --quiet --reference :mirror :path')
240
- .run(dir: File.join(abs_clone_path, pwd).to_s,
241
- mirror: mirror.to_s,
242
- path: submodule_path.to_s)
242
+ Terrapin::CommandLine.new('cd', ':dir; git submodule update --quiet --reference :mirror :path')
243
+ .run(dir: File.join(abs_clone_path, pwd).to_s,
244
+ mirror: mirror.to_s,
245
+ path: submodule_path.to_s)
243
246
  end
244
247
 
245
248
  update_submodules(File.join(pwd, submodule_path), submodule_url)
@@ -313,15 +316,14 @@ module GitFastClone
313
316
  # that this repo has been updated on this run of fastclone
314
317
  def store_updated_repo(url, mirror, repo_name, fail_hard)
315
318
  unless Dir.exist?(mirror)
316
- Cocaine::CommandLine.new('git clone', '--mirror :url :mirror')
317
- .run(url: url.to_s, mirror: mirror.to_s)
319
+ Terrapin::CommandLine.new('git clone', '--mirror :url :mirror')
320
+ .run(url: url.to_s, mirror: mirror.to_s)
318
321
  end
319
322
 
320
- Cocaine::CommandLine.new('cd', ':path; git remote update --prune').run(path: mirror)
323
+ Terrapin::CommandLine.new('cd', ':path; git remote update --prune').run(path: mirror)
321
324
 
322
325
  reference_updated[repo_name] = true
323
-
324
- rescue Cocaine::ExitStatusError => e
326
+ rescue Terrapin::ExitStatusError => e
325
327
  # To avoid corruption of the cache, if we failed to update or check out we remove
326
328
  # the cache directory entirely. This may cause the current clone to fail, but if the
327
329
  # underlying error from git is transient it will not affect future clones.
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Version string for git-fastclone
2
4
  module GitFastCloneVersion
3
- VERSION = '1.1.2'.freeze
5
+ VERSION = '1.2.0'.freeze
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2015 Square Inc.
2
4
 
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,8 +32,9 @@ describe GitFastClone::Runner do
30
32
  lockfile
31
33
  end
32
34
 
33
- # Modified ARGV, watch out
34
- ARGV = ['ssh://git@git.com/git-fastclone.git', 'test_reference_dir']
35
+ before do
36
+ stub_const('ARGV', ['ssh://git@git.com/git-fastclone.git', 'test_reference_dir'])
37
+ end
35
38
 
36
39
  let(:yielded) { [] }
37
40
 
@@ -72,14 +75,14 @@ describe GitFastClone::Runner do
72
75
 
73
76
  describe '.clone' do
74
77
  it 'should clone correctly' do
75
- cocaine_commandline_double = double('new_cocaine_commandline')
78
+ terrapin_commandline_double = double('new_terrapin_commandline')
76
79
  allow(subject).to receive(:with_git_mirror) {}
77
- allow(cocaine_commandline_double).to receive(:run) {}
78
- allow(Cocaine::CommandLine).to receive(:new) { cocaine_commandline_double }
80
+ allow(terrapin_commandline_double).to receive(:run) {}
81
+ allow(Terrapin::CommandLine).to receive(:new) { terrapin_commandline_double }
79
82
 
80
83
  expect(Time).to receive(:now).twice { 0 }
81
- expect(Cocaine::CommandLine).to receive(:new)
82
- expect(cocaine_commandline_double).to receive(:run)
84
+ expect(Terrapin::CommandLine).to receive(:new)
85
+ expect(terrapin_commandline_double).to receive(:run)
83
86
 
84
87
  subject.clone(placeholder_arg, placeholder_arg, '.')
85
88
  end
@@ -104,7 +107,7 @@ describe GitFastClone::Runner do
104
107
  describe '.thread_update_submodule' do
105
108
  it 'should update correctly' do
106
109
  pending('need to figure out how to test this')
107
- fail
110
+ raise
108
111
  end
109
112
  end
110
113
 
@@ -127,7 +130,7 @@ describe GitFastClone::Runner do
127
130
 
128
131
  expect do
129
132
  subject.with_reference_repo_lock(test_url_valid) do
130
- fail placeholder_arg
133
+ raise placeholder_arg
131
134
  end
132
135
  end.to raise_error(placeholder_arg)
133
136
  end
@@ -184,7 +187,7 @@ describe GitFastClone::Runner do
184
187
  end
185
188
  end
186
189
 
187
- let(:placeholder_hash) { Hash.new }
190
+ let(:placeholder_hash) { {} }
188
191
 
189
192
  context 'when already have a hash' do
190
193
  it 'should not store' do
@@ -218,7 +221,7 @@ describe GitFastClone::Runner do
218
221
  it 'should go through the submodule file properly' do
219
222
  expect(Thread).to receive(:new).exactly(3).times
220
223
 
221
- allow(File).to receive(:readlines) { %w(1 2 3) }
224
+ allow(File).to receive(:readlines) { %w[1 2 3] }
222
225
  subject.prefetch_submodules = true
223
226
  subject.prefetch(placeholder_arg)
224
227
  end
@@ -226,22 +229,22 @@ describe GitFastClone::Runner do
226
229
 
227
230
  describe '.store_updated_repo' do
228
231
  context 'when fail_hard is true' do
229
- it 'should raise a Cocaine error' do
230
- cocaine_commandline_double = double('new_cocaine_commandline')
231
- allow(cocaine_commandline_double).to receive(:run) { fail Cocaine::ExitStatusError }
232
- allow(Cocaine::CommandLine).to receive(:new) { cocaine_commandline_double }
232
+ it 'should raise a Terrapin error' do
233
+ terrapin_commandline_double = double('new_terrapin_commandline')
234
+ allow(terrapin_commandline_double).to receive(:run) { raise Terrapin::ExitStatusError }
235
+ allow(Terrapin::CommandLine).to receive(:new) { terrapin_commandline_double }
233
236
  expect(FileUtils).to receive(:remove_entry_secure).with(placeholder_arg, force: true)
234
237
  expect do
235
238
  subject.store_updated_repo(placeholder_arg, placeholder_arg, placeholder_arg, true)
236
- end.to raise_error(Cocaine::ExitStatusError)
239
+ end.to raise_error(Terrapin::ExitStatusError)
237
240
  end
238
241
  end
239
242
 
240
243
  context 'when fail_hard is false' do
241
- it 'should not raise a cocaine error' do
242
- cocaine_commandline_double = double('new_cocaine_commandline')
243
- allow(cocaine_commandline_double).to receive(:run) { fail Cocaine::ExitStatusError }
244
- allow(Cocaine::CommandLine).to receive(:new) { cocaine_commandline_double }
244
+ it 'should not raise a terrapin error' do
245
+ terrapin_commandline_double = double('new_terrapin_commandline')
246
+ allow(terrapin_commandline_double).to receive(:run) { raise Terrapin::ExitStatusError }
247
+ allow(Terrapin::CommandLine).to receive(:new) { terrapin_commandline_double }
245
248
  expect(FileUtils).to receive(:remove_entry_secure).with(placeholder_arg, force: true)
246
249
 
247
250
  expect do
@@ -250,12 +253,12 @@ describe GitFastClone::Runner do
250
253
  end
251
254
  end
252
255
 
253
- let(:placeholder_hash) { Hash.new }
256
+ let(:placeholder_hash) { {} }
254
257
 
255
258
  it 'should correctly update the hash' do
256
- cocaine_commandline_double = double('new_cocaine_commandline')
257
- allow(cocaine_commandline_double).to receive(:run) {}
258
- allow(Cocaine::CommandLine).to receive(:new) { cocaine_commandline_double }
259
+ terrapin_commandline_double = double('new_terrapin_commandline')
260
+ allow(terrapin_commandline_double).to receive(:run) {}
261
+ allow(Terrapin::CommandLine).to receive(:new) { terrapin_commandline_double }
259
262
  allow(Dir).to receive(:chdir) {}
260
263
 
261
264
  subject.reference_updated = placeholder_hash
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2015 Square Inc.
2
4
 
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec/core'
2
4
  require 'rspec/mocks'
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.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Tauraso
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-02 00:00:00.000000000 Z
12
+ date: 2019-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: cocaine
15
+ name: colorize
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
@@ -26,21 +26,21 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: colorize
29
+ name: terrapin
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: 0.6.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
42
- description: A git command that uses reference repositories and threading to quickly
43
- and recursively clone repositories with many nested submodules
41
+ version: 0.6.0
42
+ description: A git command that uses reference repositories and threading to quicklyand
43
+ recursively clone repositories with many nested submodules
44
44
  email:
45
45
  - mtauraso@squareup.com
46
46
  - jchang@squareup.com
@@ -77,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubyforge_project:
81
- rubygems_version: 2.5.1
80
+ rubygems_version: 3.0.2
82
81
  signing_key:
83
82
  specification_version: 4
84
83
  summary: git-clone --recursive on steroids!