Skip to content

Commit 4ee3e34

Browse files
author
TJ Biddle
committed
Adding support for submodules.
1 parent 26e6242 commit 4ee3e34

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/git/base.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ def self.init(working_dir, opts = {})
2424
:working_directory => working_dir,
2525
:repository => File.join(working_dir, '.git')
2626
}.merge(opts)
27-
27+
2828
FileUtils.mkdir_p(opts[:working_directory]) if opts[:working_directory] && !File.directory?(opts[:working_directory])
29-
29+
30+
# Submodules have a .git *file* not a .git folder.
31+
# This file's contents point to the location of
32+
# where the git refs are held (In the parent repo)
33+
if File.file?('.git')
34+
git_file = File.open('.git').read[8..-1].strip
35+
opts[:repository] = git_file
36+
opts[:index] = git_file + '/index'
37+
end
38+
3039
# run git_init there
3140
Git::Lib.new(opts).init
3241

0 commit comments

Comments
 (0)