summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xextra/prepare-commit-msg34
1 files changed, 34 insertions, 0 deletions
diff --git a/extra/prepare-commit-msg b/extra/prepare-commit-msg
new file mode 100755
index 00000000..53dffb4f
--- /dev/null
+++ b/extra/prepare-commit-msg
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+[ -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
+ fi
+ elif [[ "$line" == *"vorgemerkte Ă„nderungen"* ]] || [[ "$line" == *"to be committed"* ]]; then
+ inblock=true
+ fi
+done < "$1"
+
+[ "${#stuff[@]}" -gt 2 ] && exit 0
+[ "${#stuff[@]}" -lt 1 ] && exit 0
+
+out=""
+for key in "${!stuff[@]}"; do
+ out+="/$key"
+ #echo "$key = ${stuff["$key"]}"
+done
+sed -i "1s~^~[${out:1}] ~" "$1"
+