mirror of
https://github.com/periph/host.git
synced 2026-10-24 17:19:18 +03:00
Expose fix, verify, test, and help through consistent Make targets, with locked uv tools, EditorConfig, versioned hooks, shared binary checks, and generated agent file indexes. Apply safe lint fixes and formatting quietly while preserving diagnostics and failure exit codes. Require Go 1.26 and read CI toolchains from go.mod. Track lint and license tools in the root module; run pinned actionlint separately because of YAML dependency conflicts. Run vet through golangci-lint and retain distinct compile/link and module-tidiness checks. Refresh Actions and share setup where applicable. Ignore Codecov and coverage artifacts on Unix and Windows while keeping plain Git status checks for tracked changes and unexpected output. Run historical benchmark comparisons and their tool setup only on Ubuntu. Preserve platform and architecture coverage and downstream devices/cmd consumer gates while sharing runtime and static-check setup. Validation: make fix and make verify pass. Applicable test, generation, race, cross-build, and consumer checks passed during implementation. Formatter diagnostic fixtures, ignore-rule fixtures, index checks, and staged hooks pass. Native hosted OS and physical hardware execution remain outside local validation. Squashing preserves the validated file tree exactly.
76 lines
1.8 KiB
Bash
Executable File
76 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright 2026 Marc-Antoine Ruel. All rights reserved.
|
|
# Use of this source code is governed under the Apache License, Version 2.0
|
|
# that can be found in the LICENSE file.
|
|
|
|
# Rejects malformed, overlong, or co-authored commit messages.
|
|
|
|
set -euo pipefail
|
|
|
|
print_commit_guidance() {
|
|
printf '%s\n' \
|
|
'Commit guidance for coding agents:' \
|
|
' - Use a concise subject no longer than 120 characters.' \
|
|
' - Separate an optional body from the subject with a blank line.' \
|
|
' - When useful, explain the rationale and tradeoffs; do not restate the diff.' >&2
|
|
}
|
|
|
|
if (($# != 1)); then
|
|
printf '%s\n' 'Usage: commit-msg <message-file>' >&2
|
|
print_commit_guidance
|
|
exit 2
|
|
fi
|
|
|
|
message_file=$1
|
|
readonly message_file
|
|
|
|
if [[ ! -f "$message_file" ]]; then
|
|
printf 'Commit message file does not exist: %s\n' "$message_file" >&2
|
|
print_commit_guidance
|
|
exit 2
|
|
fi
|
|
|
|
if grep -Fq '\n' "$message_file"; then
|
|
printf '%s\n' 'Commit messages must use actual line breaks, not literal \n sequences.' >&2
|
|
print_commit_guidance
|
|
exit 1
|
|
fi
|
|
|
|
if grep -Eiq '^co-authored-by: ' "$message_file"; then
|
|
printf '%s\n' 'Commit messages must not contain Co-authored-by trailers.' >&2
|
|
print_commit_guidance
|
|
exit 1
|
|
fi
|
|
|
|
if ! awk '
|
|
/^[[:space:]]*#/ { next }
|
|
!subject {
|
|
if (NF) subject = 1
|
|
next
|
|
}
|
|
!separator {
|
|
if (!NF) {
|
|
separator = 1
|
|
next
|
|
}
|
|
invalid_separator = 1
|
|
next
|
|
}
|
|
END { exit !subject || invalid_separator }
|
|
' "$message_file"; then
|
|
printf '%s\n' 'Commit messages need a subject and a blank line before any body.' >&2
|
|
print_commit_guidance
|
|
exit 1
|
|
fi
|
|
|
|
if ! awk '
|
|
/^[[:space:]]*#/ { next }
|
|
NF && length($0) > 120 {
|
|
printf "Commit message line %d is %d characters; maximum is 120.\n", NR, length($0) > "/dev/stderr"
|
|
exit 1
|
|
}
|
|
' "$message_file"; then
|
|
print_commit_guidance
|
|
exit 1
|
|
fi
|