Index: .hooks/pre-commit.d/check_moved =================================================================== --- /dev/null +++ .hooks/pre-commit.d/check_moved @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Check that added MOVED lines follow the proper scheme +# + +moved_changed=$(git diff --name-only --cached --diff-filter=M | grep -E '^MOVED$') +if [ $? -eq 0 ] ; then + # * only check the lines that are added, there should not be an error when fixing broken lines + # * each line is checked against + # port|new_port?|yyyy-mm-dd|reason + broken_lines=$( git diff -U0 --cached MOVED | \ + grep '^\+[^+]' | \ + sed 's|^\+\([^+].*$\)|\1|' | \ + grep -v '^([^\/]+\/[^\/]+)\|([^\/]+\/[^\/]+)?\|([0-9]{4}-[0-9]{2}-[0-9]{2})\|([^\|]+)$') + if [ $? -eq 0 ] ; then + echo "[pre-commit] ERROR: MOVED lines:" + echo "${broken_lines}" + echo "is/are invalid -- please run Tools/scripts/MOVEDlint.awk" + exit 1 + fi +fi