@@ -10,44 +10,55 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010source " ${SCRIPT_DIR} /../utils/colors.sh"
1111source " ${SCRIPT_DIR} /../utils/git-utils.sh"
1212
13+ emit_status () {
14+ [[ " ${DEVBASE_CHECK_MARKERS:- 0} " == " 1" ]] || return 0
15+ printf " DEVBASE_CHECK_STATUS=%s\n" " $1 "
16+ [[ -n " ${2:- } " ]] && printf " DEVBASE_CHECK_DETAILS=%s\n" " $2 "
17+ }
18+
1319main () {
14- print_header " COMMIT HEALTH (GOMMITLINT)"
15-
16- local current_branch default_branch
17- current_branch=$( git branch --show-current)
18- default_branch=$( get_default_branch)
19-
20- # Skip if on the base branch itself (gommitlint can't handle base..HEAD when they're the same)
21- if [[ " $current_branch " == " $default_branch " ]]; then
22- print_info " On ${default_branch} - no commits to check against base branch"
23- return 0
24- fi
25-
26- if ! has_commits_since " $default_branch " ; then
27- print_info " No commits to check on ${current_branch} (compared to ${default_branch} )"
28- return 0
29- fi
30-
31- # Detect SHA-256 repo and select correct binary
32- # See: https://github.com/go-git/go-git/issues/706
33- local gommitlint_cmd=" gommitlint"
34- if git rev-parse --show-object-format 2> /dev/null | grep -q sha256; then
35- gommitlint_cmd=" gommitlint-sha256"
36- fi
37-
38- if ! command -v " $gommitlint_cmd " > /dev/null 2>&1 ; then
39- print_warning " ${gommitlint_cmd} not found in PATH - skipping commit linting"
40- echo " Install: mise install"
41- return 0
42- fi
43-
44- if $gommitlint_cmd validate --base-branch=" ${default_branch} " 2> /dev/null; then
45- print_success " Commit health check passed"
46- return 0
47- else
48- print_error " Commit health check failed - check your commit messages"
49- return 1
50- fi
20+ print_header " COMMIT HEALTH (GOMMITLINT)"
21+
22+ local current_branch default_branch
23+ current_branch=$( git branch --show-current)
24+ default_branch=$( get_default_branch)
25+
26+ # Skip if on the base branch itself (gommitlint can't handle base..HEAD when they're the same)
27+ if [[ " $current_branch " == " $default_branch " ]]; then
28+ print_info " On ${default_branch} - no commits to check against base branch"
29+ emit_status " na" " n/a"
30+ return 0
31+ fi
32+
33+ if ! has_commits_since " $default_branch " ; then
34+ print_info " No commits to check on ${current_branch} (compared to ${default_branch} )"
35+ emit_status " na" " n/a"
36+ return 0
37+ fi
38+
39+ # Detect SHA-256 repo and select correct binary
40+ # See: https://github.com/go-git/go-git/issues/706
41+ local gommitlint_cmd=" gommitlint"
42+ if git rev-parse --show-object-format 2> /dev/null | grep -q sha256; then
43+ gommitlint_cmd=" gommitlint-sha256"
44+ fi
45+
46+ if ! command -v " $gommitlint_cmd " > /dev/null 2>&1 ; then
47+ print_warning " ${gommitlint_cmd} not found in PATH - skipping commit linting"
48+ echo " Install: mise install"
49+ emit_status " skip" " not in PATH"
50+ return 0
51+ fi
52+
53+ if $gommitlint_cmd validate --base-branch=" ${default_branch} " 2> /dev/null; then
54+ print_success " Commit health check passed"
55+ emit_status " pass" " ok"
56+ return 0
57+ else
58+ print_error " Commit health check failed - check your commit messages"
59+ emit_status " fail" " failed"
60+ return 1
61+ fi
5162}
5263
5364main
0 commit comments