Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 54 lines (44 sloc) 1.17 KB
#!/bin/bash
set -e -u -o pipefail
markdown_files_being_committed() {
git diff --cached --name-only --diff-filter=ACM \
| (grep ^content/blog || true)
}
# Hugo doesn't publish drafts, so prevent checking in draft content.
check_for_drafts() {
local drafts_found=0 file
for file in $(markdown_files_being_committed); do
if grep -H --color=auto '^draft.*=.*true' "${file}"; then
drafts_found=1
fi
done
if [[ "${drafts_found}" -eq 1 ]]; then
printf "draft entries found\\n" >&2
fi
return "${drafts_found}"
}
# When tags are inconsistently capitalised Hugo will use a random tag, causing
# unnecessary changes in output. Prevent checking in inconsistent tags.
check_for_inconsistent_tags() {
local bad_tags
bad_tags="$(make --quiet tags_list \
| awk '{print tolower($2)}' \
| sort \
| uniq -d)"
if [[ -z "${bad_tags}" ]]; then
return 0
fi
printf "Inconsistent tag capitalisation found: %s\\n" "${bad_tags}"
return 1
}
main() {
local exit_status=0
if ! check_for_drafts; then
exit_status=1
fi
if ! check_for_inconsistent_tags; then
exit_status=1
fi
exit "${exit_status}"
}
main
You can’t perform that action at this time.