Skip to content

Handle opening a working directory for a submodule. #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Handle opening a working directory for a submodule.
Signed-off-by: Rick Pocklington <rick.pocklington@bluemedora.com>
  • Loading branch information
rpocklington committed Oct 28, 2019
commit a93264dd7876cce32545bc0ab4bede3b7129274b
13 changes: 11 additions & 2 deletions lib/git/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ def self.open(working_dir, opts={})

def initialize(options = {})
if working_dir = options[:working_directory]
options[:repository] ||= File.join(working_dir, '.git')
options[:index] ||= File.join(working_dir, '.git', 'index')
# Submodules have a .git *file* not a .git folder.
# This file's contents point to the location of
# where the git refs are held (In the parent repo)
working_dir_git_file = File.join(working_dir, '.git')
if File.file?(working_dir_git_file)
git_file = File.open(working_dir_git_file).read[8..-1].strip
options[:repository] ||= git_file
else
options[:repository] ||= working_dir_git_file
end
options[:index] ||= File.join(options[:repository], 'index')
end
if options[:log]
@logger = options[:log]
Expand Down