summaryrefslogtreecommitdiffstats
path: root/extra
diff options
context:
space:
mode:
authorSimon Rettberg2019-01-29 13:44:14 +0100
committerSimon Rettberg2019-01-29 13:44:14 +0100
commit49adc21d2c47fe079793b4c63b5d222d70e57df6 (patch)
treeedc6476c12890d5bb777c8d25d3e8c772e2e2a29 /extra
parent[dnbd3-proxy-mode] Watch for hash check fails and log to server (diff)
downloadmltk-49adc21d2c47fe079793b4c63b5d222d70e57df6.tar.gz
mltk-49adc21d2c47fe079793b4c63b5d222d70e57df6.tar.xz
mltk-49adc21d2c47fe079793b4c63b5d222d70e57df6.zip
commitmsg-hook: Simplify filename parsing
Also it now works if you're not in the repo's root dir
Diffstat (limited to 'extra')
-rwxr-xr-xextra/prepare-commit-msg19
1 files changed, 6 insertions, 13 deletions
diff --git a/extra/prepare-commit-msg b/extra/prepare-commit-msg
index 53dffb4f..9948d543 100755
--- a/extra/prepare-commit-msg
+++ b/extra/prepare-commit-msg
@@ -3,24 +3,17 @@
[ -n "$2" ] && exit 0
[ -e "$1" ] || exit 1
-# -F 'to be commited' -F 'vorgemerkte Ă„nderungen'
-inblock=false
declare -A stuff
re='core/(modules|rootfs)/([^/]+)/'
while IFS='' read -r line || [[ -n "$line" ]]; do
- if $inblock; then
- [ "$line" = '#' ] && break
- if [[ $line =~ $re ]]; then
- if [ -z "${stuff["${BASH_REMATCH[2]}"]}" ]; then
- stuff["${BASH_REMATCH[2]}"]=1
- else
- let stuff["${BASH_REMATCH[2]}"]++
- fi
+ if [[ $line =~ $re ]]; then
+ if [ -z "${stuff["${BASH_REMATCH[2]}"]}" ]; then
+ stuff["${BASH_REMATCH[2]}"]=1
+ else
+ let stuff["${BASH_REMATCH[2]}"]++
fi
- elif [[ "$line" == *"vorgemerkte Ă„nderungen"* ]] || [[ "$line" == *"to be committed"* ]]; then
- inblock=true
fi
-done < "$1"
+done < <( git status --porcelain | grep -E '^(A|M|D)' )
[ "${#stuff[@]}" -gt 2 ] && exit 0
[ "${#stuff[@]}" -lt 1 ] && exit 0