mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-19 14:17:40 +00:00
chore(common/resources): update prepare-commit-msg with global scopes
This commit is contained in:
parent
c60df18ee0
commit
d64014734b
1 changed files with 13 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#
|
||||
# This prepare-commit-msg hook prepares commit messages to ensure
|
||||
# This prepare-commit-msg hook prepares commit messages to ensure
|
||||
# that they meet our conventional commit standard.
|
||||
#
|
||||
# Whenever `git` detects an incoming commit, it will trigger this hook. If the message does not
|
||||
|
|
@ -20,7 +20,16 @@ SHA1=$3
|
|||
# Get the directory where this script lives, i.e. resources/git-hooks
|
||||
HOOK_DIRECTORY="$(dirname "$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")")"
|
||||
|
||||
. $HOOK_DIRECTORY/commit-msg-defs
|
||||
. "$HOOK_DIRECTORY/../build/jq.inc.sh"
|
||||
. "$HOOK_DIRECTORY/commit-msg-defs"
|
||||
|
||||
#
|
||||
# Read from our globally shared JSON-formatted scopes and types
|
||||
#
|
||||
|
||||
scopes=( $("$JQ" -r '[.scopes | paths | reduce .[] as $item (""; if . == "" then $item else . + "/" + $item end)] | join(" ")' < "$HOOK_DIRECTORY/../scopes/scopes.json") )
|
||||
types=( $("$JQ" -r '.commitTypes | join(" ")' < "$HOOK_DIRECTORY/../scopes/commit-types.json") )
|
||||
|
||||
|
||||
# build the regex pattern based on the config file
|
||||
function build_regex() {
|
||||
|
|
@ -83,7 +92,7 @@ function prepend_scope() {
|
|||
postfix=""
|
||||
fi
|
||||
prefix="$TYPE($SCOPE): $EXTRA_WHITESPACE"
|
||||
|
||||
|
||||
# Reuse any existing message text, wrapping it in our conventional commit formatting before
|
||||
# presenting it to the user for any final edits.
|
||||
echo -e "$prefix$(cat $COMMIT_MSG_FILE)$postfix" > $COMMIT_MSG_FILE
|
||||
|
|
@ -98,7 +107,7 @@ function prepend_scope() {
|
|||
|
||||
# Step 1 - is the prepared message already in our conventional commits format?
|
||||
$HOOK_DIRECTORY/commit-msg -q $COMMIT_MSG_FILE
|
||||
isConventional=$? # Grabs the exit code.
|
||||
isConventional=$? # Grabs the exit code.
|
||||
|
||||
if [ $isConventional -eq 0 ]; then
|
||||
# If so, great! Don't do a thing!
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue