Changeset View
Changeset View
Standalone View
Standalone View
.hooks/pre-commit.d/check_portepoch
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
#!/bin/sh | |||||||||
# | |||||||||
# Check that PORTEPOCH is not being dropped, and is non-decreasing | |||||||||
# | |||||||||
check_epoch() { | |||||||||
local makefile="$1" | |||||||||
local old_epoch=$(git diff --cached -U0 "${makefile}" | grep '^\-PORTEPOCH' | grep -oE '[0-9]+') | |||||||||
local new_epoch=$(git diff --cached -U0 "${makefile}" | grep '^\+PORTEPOCH' | grep -oE '[0-9]+') | |||||||||
if [ -z "${new_epoch}" ] ; then | |||||||||
echo "[pre-commit] dropped PORTEPOCH ${old_epoch} in ${makefile}" | |||||||||
rene: How does this check that old_epoch was set? | |||||||||
Done Inline Actions
we've had -n/-z for a while now, compounded with @rene 's remark. mat: we've had -n/-z for a while now, compounded with @rene 's remark. | |||||||||
Done Inline Actionsswitched to using -n and -z respectively tcberner: switched to using `-n` and `-z` respectively | |||||||||
exit 1 | |||||||||
fi | |||||||||
if [ -n "${old_epoch}" ] ; then | |||||||||
if [ ${new_epoch} -lt ${old_epoch} ] ; then | |||||||||
echo "[pre-commit] PORTEPOCH decreasing from ${old_epoch} to ${new_epoch} in ${makefile}" | |||||||||
exit 2 | |||||||||
fi | |||||||||
fi | |||||||||
} | |||||||||
modified_makefiles=$(git diff --name-only --cached --diff-filter=M -GPORTEPOCH | grep -E '^[^/]+/[^/]+/Makefile$') | |||||||||
if [ $? -eq 0 ] ; then | |||||||||
for modified_makefile in ${modified_makefiles} ; do | |||||||||
check_epoch ${modified_makefile} | |||||||||
done | |||||||||
fi |
How does this check that old_epoch was set?