2023-01-09 21:06:46 -08:00
|
|
|
{{- if (eq .host.distro.family "linux") -}}
|
2023-01-09 16:17:40 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
2023-01-24 10:06:47 -08:00
|
|
|
{{ $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 }}
|
|
|
|
|
2023-01-24 17:14:55 -08:00
|
|
|
### Ensure git hooks directory exists
|
|
|
|
logg info 'Ensuring git hooks directory exists'
|
|
|
|
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks"
|
|
|
|
|
2023-01-24 10:06:47 -08:00
|
|
|
### Ensure git hooks are executable
|
2023-01-24 17:14:55 -08:00
|
|
|
logg info 'Ensuring git hooks are up-to-date'
|
2023-01-24 10:06:47 -08:00
|
|
|
find "$HOME/.local/src/shared-common/common/.config/husky" -mindepth 1 -maxdepth 1 -type f | while read HOOK; do
|
2023-01-24 17:14:55 -08:00
|
|
|
cp "$HOOK" "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks"
|
2023-01-09 16:17:40 -08:00
|
|
|
done
|
|
|
|
|
2023-01-24 17:14:55 -08:00
|
|
|
### Make git hooks executable
|
|
|
|
if [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks" ]; then
|
|
|
|
logg info 'Ensuring git hooks are executable'
|
2023-01-24 19:51:09 -08:00
|
|
|
chmod +x "${XDG_CONFIG_HOME:-$HOME/.config}/git/template/hooks/"*
|
2023-01-24 17:14:55 -08:00
|
|
|
fi
|
|
|
|
|
2023-01-09 16:17:40 -08:00
|
|
|
{{ end -}}
|