mirror of
https://git.freebsd.org/ports.git
synced 2025-04-28 09:36:41 -04:00
Add common error function in hooks Error messages are printed in stderr Reviewed By: tcberner, #portmgr Differential Revision: https://reviews.freebsd.org/D38026
25 lines
708 B
Bash
Executable file
25 lines
708 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Check that newly added MOVED lines are valid
|
|
#
|
|
|
|
common_functions="$(realpath "$(dirname "$0")")/common.sh"
|
|
if [ -r "${common_functions}" ]; then
|
|
. "${common_functions}"
|
|
fi
|
|
|
|
moved_changed=$(git diff --name-only --cached --diff-filter=M | grep -E '^MOVED$')
|
|
if [ $? -eq 0 ] ; then
|
|
# git changes to root directory of the tree to run hooks
|
|
tree=$(git rev-parse --show-toplevel)
|
|
# check the last seven days
|
|
lastdate=$(date -v-7d "+%Y-%m-%d")
|
|
|
|
errors=$(PORTSDIR=${tree} Tools/scripts/MOVEDlint.awk -v lastdate="${lastdate}")
|
|
if [ $? -ne 0 ] ; then
|
|
pre_commit_error "MOVED contains errors.\n" \
|
|
" Please apply the suggested changes:\n"
|
|
error "${errors}"
|
|
exit 1
|
|
fi
|
|
fi
|