blob: 9948d543f0aed0965626f1089d45ebac95d3e658 (
plain) (
tree)
|
|
#!/bin/bash
[ -n "$2" ] && exit 0
[ -e "$1" ] || exit 1
declare -A stuff
re='core/(modules|rootfs)/([^/]+)/'
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line =~ $re ]]; then
if [ -z "${stuff["${BASH_REMATCH[2]}"]}" ]; then
stuff["${BASH_REMATCH[2]}"]=1
else
let stuff["${BASH_REMATCH[2]}"]++
fi
fi
done < <( git status --porcelain | grep -E '^(A|M|D)' )
[ "${#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"
|