install.fairie/home/.chezmoiscripts/universal/run_onchange_after_08-git-hooks.tmpl
Brian Zalewski 7bfe2ddbf1 Update 9 files
- /home/dot_config/git/template/hooks/symlink_commit-msg.tmpl
- /home/dot_config/git/template/hooks/symlink_post-checkout.tmpl
- /home/dot_config/git/template/hooks/symlink_post-commit.tmpl
- /home/dot_config/git/template/hooks/symlink_post-merge.tmpl
- /home/dot_config/git/template/hooks/symlink_post-rewrite.tmpl
- /home/dot_config/git/template/hooks/symlink_pre-commit.tmpl
- /home/dot_config/git/template/hooks/symlink_pre-push.tmpl
- /home/dot_config/git/template/hooks/symlink_prepare-commit-msg.tmpl
- /home/.chezmoiscripts/universal/run_onchange_after_08-git-hooks.tmpl
2023-01-25 01:14:55 +00:00

30 lines
1.1 KiB
Cheetah

{{- if (eq .host.distro.family "linux") -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ $gitHooks := (output "find" (joinPath .chezmoi.homeDir ".local" "src" "shared-common" "common" ".config" "husky") "-mindepth" "1" "-maxdepth" "1" "-type" "f") -}}
{{- range $gitHook := splitList "\n" $gitHooks -}}
{{- if ne $gitHook "" -}}
# {{ $gitHook }} hash: {{ include $gitHook | sha256sum }}
{{- end -}}
{{- end }}
### Ensure git hooks directory exists
logg info 'Ensuring git hooks directory exists'
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks"
### Ensure git hooks are executable
logg info 'Ensuring git hooks are up-to-date'
find "$HOME/.local/src/shared-common/common/.config/husky" -mindepth 1 -maxdepth 1 -type f | while read HOOK; do
cp "$HOOK" "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks"
done
### Make git hooks executable
if [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks" ]; then
logg info 'Ensuring git hooks are executable'
chmod +x "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks/*"
fi
{{ end -}}