2019-03-01 16:38:37 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-03-01 16:58:10 +01:00
|
|
|
# This is post-merge git hook script to check for changes in:
|
|
|
|
# * git hook scripts
|
|
|
|
# * helper scripts for using git efficiently.
|
|
|
|
# If any changes are detected, a diff of them is printed.
|
|
|
|
#
|
|
|
|
# To install this script, copy it to .git/hooks/post-merge in local copy of
|
|
|
|
# tor git repo and make sure it has permission to execute.
|
|
|
|
|
2019-03-01 16:38:37 +01:00
|
|
|
git_toplevel=$(git rev-parse --show-toplevel)
|
|
|
|
|
|
|
|
check_for_diffs() {
|
|
|
|
installed="$git_toplevel/.git/hooks/$1"
|
2019-03-06 18:53:50 +01:00
|
|
|
latest="$git_toplevel/scripts/git/$1.git-hook"
|
2019-03-01 16:38:37 +01:00
|
|
|
|
|
|
|
if [ -e "$installed" ]
|
|
|
|
then
|
|
|
|
if ! cmp "$installed" "$latest" >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
echo "ATTENTION: $1 hook has changed:"
|
|
|
|
echo "==============================="
|
2019-03-06 18:55:38 +01:00
|
|
|
diff -u "$installed" "$latest"
|
2019-03-01 16:38:37 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-03-01 16:54:54 +01:00
|
|
|
check_for_script_update() {
|
2019-03-06 18:53:50 +01:00
|
|
|
fullpath="$1"
|
2019-03-01 16:54:54 +01:00
|
|
|
|
2019-03-06 18:42:29 +01:00
|
|
|
if ! git diff ORIG_HEAD HEAD --exit-code -- "$fullpath" >/dev/null
|
|
|
|
then
|
|
|
|
echo "ATTENTION: $1 has changed:"
|
2019-03-08 17:50:49 +01:00
|
|
|
git --no-pager diff ORIG_HEAD HEAD -- "$fullpath"
|
2019-03-06 18:42:29 +01:00
|
|
|
fi
|
2019-03-01 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2019-07-02 19:06:23 +02:00
|
|
|
cur_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
if [ "$cur_branch" != "master" ]; then
|
|
|
|
echo "post-merge: Not a master branch. Skipping."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-03-01 16:38:37 +01:00
|
|
|
check_for_diffs "pre-push"
|
|
|
|
check_for_diffs "pre-commit"
|
|
|
|
check_for_diffs "post-merge"
|
|
|
|
|
2019-03-06 18:53:50 +01:00
|
|
|
for file in "$git_toplevel"/scripts/git/* ; do
|
|
|
|
check_for_script_update "$file"
|
|
|
|
done
|
|
|
|
|