git-fastclone 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of git-fastclone might be problematic. Click here for more details.

Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git-fastclone.rb +16 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a85f561194735fe055a64ba237dce16864164353
4
- data.tar.gz: 65e1d6e97ccca28959f2cef272731906d2e0025d
3
+ metadata.gz: 153c297d291e6ad8edcb66333438e70a4babfcfe
4
+ data.tar.gz: a3df048e6e1ab5e900e341513cb20248d996896d
5
5
  SHA512:
6
- metadata.gz: 1f8df5fcfdad9d2b81106ea838ee36db56685b7e6bddd5964760711805151be514cbfa1129f4efe21f2ea2fe2edd1eec6bc681b9ea36bbff4c1ae25226ccee6e
7
- data.tar.gz: b16efd9892062ea5ca88daac81d92b46f97689a951b31354c92f39fde6db35f0fd675df58ed9b92967089256458b415cfb8d17f295eb181ff21a6b5428145446
6
+ metadata.gz: 1f31a2cdd9cb886b3af613a639dc5992eb5653c69b116e506e701053a037a0e25223cee0a6d7241220d9138c71b4351db54afc91215b5dce3ad3a9f364bb1acf
7
+ data.tar.gz: bf0c7a716e84db621438ee3b5ef58df7f46349a92c7a1d875d8aa3b32b5f0e2239c63220d3df8bed84b8ba03d7c2b26c2882496effc71006315be0e5ae8673aa
@@ -26,26 +26,26 @@ class GitFastClone
26
26
  # One option --branch=<branch> We're not as brittle as clone. That branch can be a sha or tag and we're still okay.
27
27
  @options = {}
28
28
  OptionParser.new do |opts|
29
+ opts.banner = "Usage: git fastclone [options] <git-url> [path]"
29
30
  @options[:branch] = nil
30
31
  opts.on("-b", "--branch BRANCH", "Checkout this branch rather than the default") do |branch|
31
32
  @options[:branch] = branch
32
33
  end
33
- # TODO: Add help text.
34
34
  end.parse!
35
35
 
36
- puts ARGV
37
-
38
36
  # Remaining two positional args are url and optional path
39
37
  url = ARGV[0]
40
38
  path = ARGV[1] || path_from_git_url(url)
41
39
 
40
+ puts "Cloning #{url} to #{path}"
41
+
42
42
  # Do a checkout with reference repositories for main and submodules
43
- clone(url, @options[:branch], File.join(Dir.pwd, path))
43
+ clone(url, @options[:branch], path)
44
44
  end
45
45
 
46
46
  def path_from_git_url(url)
47
47
  # Get the checkout path from tail-end of the url.
48
- File.join(Dir.pwd, url.match(/([^\/]*)\.git$/)[1])
48
+ url.match(/([^\/]*)\.git$/)[1]
49
49
  end
50
50
 
51
51
  # Checkout to SOURCE_DIR. Update all submodules recursively. Use reference repos everywhere for speed.
@@ -53,12 +53,12 @@ class GitFastClone
53
53
  initial_time = Time.now()
54
54
 
55
55
  with_git_mirror(url) do |mirror|
56
- fail_on_error("git", "clone", "--reference", mirror, url, src_dir)
56
+ fail_on_error("git", "clone", "--quiet", "--reference", mirror, url, src_dir)
57
57
  end
58
58
 
59
59
  # Only checkout if we're changing branches to a non-default branch
60
60
  unless rev.nil? then
61
- fail_on_error("git", "checkout", rev, :chdir=>src_dir)
61
+ fail_on_error("git", "checkout", "--quiet", rev, :chdir=>src_dir)
62
62
  end
63
63
 
64
64
  update_submodules(src_dir, url)
@@ -82,7 +82,7 @@ class GitFastClone
82
82
  # Parse its output directly to save time.
83
83
  fail_on_error("git", "submodule", "init", :chdir=>pwd).split("\n").each do |line|
84
84
  # Submodule path (not name) is in between single quotes '' at the end of the line
85
- submodule_path = File.join(pwd, line.strip.match(/'([^']*)'$/)[1])
85
+ submodule_path = line.strip.match(/'([^']*)'$/)[1]
86
86
  # URL is in between parentheses ()
87
87
  submodule_url = line.strip.match(/\(([^)]*)\)/)[1]
88
88
  submodule_url_list << submodule_url
@@ -90,10 +90,10 @@ class GitFastClone
90
90
  # Each update happens on a separate thread for speed.
91
91
  threads << Thread.new do
92
92
  with_git_mirror(submodule_url) do |mirror|
93
- fail_on_error("git", "submodule", "update", "--reference", mirror, submodule_path, :chdir=>pwd)
93
+ fail_on_error("git", "submodule", "update", "--quiet", "--reference", mirror, submodule_path, :chdir=>pwd)
94
94
  end
95
95
  # Recurse into the submodule directory
96
- update_submodules(submodule_path, submodule_url)
96
+ update_submodules(File.join(pwd,submodule_path), submodule_url)
97
97
  end
98
98
  end
99
99
  update_submodule_reference(url, submodule_url_list)
@@ -174,7 +174,11 @@ class GitFastClone
174
174
  def with_git_mirror(url)
175
175
  update_reference_repo(url)
176
176
 
177
- # May want to lock the reference repo for this, but don't need to for how we use this.
178
- yield reference_repo_dir(url)
177
+ # Sometimes remote updates involve re-packing objects on a different thread
178
+ # We grab the reference repo lock here just to make sure whatever thread
179
+ # ended up doing the update is done with its housekeeping.
180
+ with_reference_repo_lock(url) do
181
+ yield reference_repo_dir(url)
182
+ end
179
183
  end
180
184
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-fastclone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Tauraso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2014-11-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A git command that uses reference repositories and threading to quickly
14
14
  and recursively clone repositories with many nested submodules