Skip to content

Commit a9daf6a

Browse files
committed
build: update kull git hooks
1 parent ac741c5 commit a9daf6a

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

.dev/githooks/commit-msg

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#!/bin/bash
2-
# shopt -s lastpipe
2+
msg="$(head -1 "$1")"
3+
# Let git handle an empty commit message
4+
case "$msg" in (""|\#*) exit 0;; esac
35

46
scopes_file=".dev/scopes.txt"
7+
# Join scopes to regex, skipping empty and commented lines
58
test -r "$scopes_file" &&
69
scopes="($(grep -vE '^\s*(#|$)' "$scopes_file" | paste -sd '|' - ))"
710

8-
head -1 "$1" | grep -Eq "^(fix|feat|enhance|docs|style|refactor|test|build|rework|release|revert)(\(${scopes:-.*}(/.+)?\))?: [A-Za-z]"
11+
echo "$msg" | grep -Eq "^(fix|feat|enhance|docs|style|refactor|test|build|rework|release|revert)(\(${scopes:-.*}(/.+)?\))?: [A-Za-z]"
912
result=$?
1013
if test $result -ne 0
11-
then printf "Invalid commit message: '$(head -1 "$1")'
12-
Please check the guidelines at http://karma-runner.github.io/6.2/dev/git-commit-msg.html$(test -n "$scopes" && echo " with the scope one of $scopes as defined in $scopes_file")" >&2
14+
then printf "Invalid commit message: '$msg'
15+
Please check the guidelines at https://karma-runner.github.io/6.4/dev/git-commit-msg.html$(test -n "$scopes" && echo " with the scope one of $scopes as defined in $scopes_file")" >&2
1316
fi
1417
exit $result

.dev/githooks/prepare-commit-msg

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
# This hook adds guidance about the commit message format
4-
# on top of the default commit message.
4+
# on top of the default commit message hints.
55
#
66
# Called by "git commit" with the name of the file that has the commit message,
77
# followed by the description of the commit message's source.
@@ -14,8 +14,9 @@ COMMIT_SOURCE=$2
1414
SHA1=$3
1515

1616
scopes_file=".dev/scopes.txt"
17-
test -r $scopes_file &&
18-
scopes="$(cat "$scopes_file" | sed '/^\(#.*\|\)$/d' | sed ':a;N;s/\n/, /g;ta')"
17+
# Join scopes to regex, skipping empty and commented lines
18+
test -r "$scopes_file" &&
19+
scopes="($(grep -vE '^\s*(#|$)' "$scopes_file" | paste -sd '|' - ))"
1920

2021
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
2122

@@ -36,16 +37,22 @@ then
3637
{
3738
# Infer type & scope from changed files
3839
expr "$path" : ".dev" >/dev/null &&
39-
printf "feat(dev): "
40+
( git config list --local | grep -q kull &&
41+
printf "feat(dev): " ||
42+
printf "build: "; )
4043
# Example for gradle projects
4144
expr "$path" : "gradle" \| "$path" : "build" >/dev/null &&
4245
printf "build(gradle): "
4346

44-
printf "\n\n# Please enter the message in the format\n"
45-
echo "# <type>(<scope>): <description>"
46-
echo "# Possible types: fix, feat, enhance, docs, style, refactor, test, build"
47-
test -n "$scopes" && echo "# Allowed scopes: $scopes"
48-
echo "# For details see https://www.notion.so/softwarechallenge/Git-217333329ea64db5b2cc8bbbaf79db87"
49-
echo "$original"
47+
echo "
48+
# Please enter the message in the format:
49+
# <type>(<scope>): <description>
50+
# Types:
51+
# - production code: fix, feat, enhance, refactor, style
52+
# - auxiliaries: docs, test, build
53+
${scopes:+# Allowed scopes: $scopes}
54+
# For details see https://kull.jfischer.org
55+
$original
56+
"
5057
} > "$COMMIT_MSG_FILE"
5158
fi

0 commit comments

Comments
 (0)