Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/overcommit/git_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def comment_character

def hooks_path
path = `git config --get core.hooksPath`.chomp
return File.join(Overcommit::Utils.repo_root, '.git', 'hooks') if path.empty?
return File.join(Overcommit::Utils.git_dir, 'hooks') if path.empty?
File.absolute_path(path)
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/overcommit/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ def hook_files_installed?(hooks_dir)
end
end
end

context 'which has an external git dir' do
let(:submodule) { File.join(target, 'submodule') }
before do
system 'git', 'submodule', 'add', target, 'submodule',
chdir: target, out: :close, err: :close
end
let(:submodule_git_file) { File.join(submodule, '.git') }
let(:submodule_git_dir) do
File.expand_path(File.read(submodule_git_file)[/gitdir: (.*)/, 1], submodule)
end
let(:submodule_hooks_dir) { File.join(submodule_git_dir, 'hooks') }

subject { installer.run(submodule, options) }

it 'installs hooks into the correct external directory' do
expect { subject }.to change {
hook_files_installed?(submodule_hooks_dir)
}.from(false).to(true)
end
end
end
end
end