fix: fixes bug in symlinking git hooks

This commit is contained in:
Menno van Leeuwen 2024-08-22 23:57:28 +02:00
parent 34671bfd42
commit f09429ba93
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE

View File

@ -23,16 +23,16 @@ secrets() {
}
ensure_git_hooks() {
# If .git/hooks is a symlink, skip this
if [[ -L .git/hooks ]]; then
# If ~/dotfiles/.git/hooks is a symlink, skip this
if [[ -L ~/dotfiles/.git/hooks ]]; then
# Let's make sure the symlink is correct
if [[ $(readlink .git/hooks) != ~/dotfiles/bin/actions/git ]]; then
printfe "%s\n" "yellow" "The .git/hooks symlink is incorrect. Please remove it and run this script again."
if [[ $(readlink ~/dotfiles/.git/hooks) != ~/dotfiles/bin/actions/git ]]; then
printfe "%s\n" "yellow" "The ~/dotfiles/.git/hooks symlink is incorrect. Please remove it and run this script again."
fi
return
fi
if [[ -d .git/hooks ]]; then
if [[ -d ~/dotfiles/.git/hooks ]]; then
rm -rf ~/dotfiles/.git/hooks
printfe "%s\n" "yellow" "The ~/dotfiles/.git/hooks directory already exists. We're removing it!"
fi