diff options
author | Simon Rettberg | 2019-01-17 14:54:58 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-01-17 14:55:44 +0100 |
commit | 9ee0a69b45a53af7f1d1708b45f74f7efc488a59 (patch) | |
tree | d28431d70d8c6195d9b1a6f8cd47475152c178b1 /extra | |
parent | [rfs-stage31] Double network setup timeout (operstate) (diff) | |
download | mltk-9ee0a69b45a53af7f1d1708b45f74f7efc488a59.tar.gz mltk-9ee0a69b45a53af7f1d1708b45f74f7efc488a59.tar.xz mltk-9ee0a69b45a53af7f1d1708b45f74f7efc488a59.zip |
Add prepare-commit-msg hook
If using vim, consider doing
git config (--global) core.editor "vim -c'startinsert|call cursor(1,200)'"
or similar.
Diffstat (limited to 'extra')
-rwxr-xr-x | extra/prepare-commit-msg | 34 |
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" + |