2023-03-18 00:28:21 -07:00
|
|
|
{{- if false -}}
|
2023-01-09 16:17:40 -08:00
|
|
|
#!/usr/bin/env bash
|
2023-03-18 00:28:21 -07:00
|
|
|
### This script is `if false` blocked out! ###
|
|
|
|
# This script is disabled until we figure out sensible git hooks for linters / auto-fixers
|
|
|
|
# that are not too aggressive. Megabyte Labs projects can install git hooks by running
|
|
|
|
# `bash start.sh`.
|
|
|
|
#
|
|
|
|
# To re-enable, add the missing files to the ~/.config/git/template folder, uncomment the templatedir line
|
|
|
|
# in ~/.config/git/config, and uncomment the Husky script in .chezmoiexternal.toml. Then, move this file to
|
|
|
|
# the universal folder.
|
2023-01-09 16:17:40 -08:00
|
|
|
|
|
|
|
{{ 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 -}}
|