Ajout hooks git de gestion de droits

This commit is contained in:
Brice Waegeneire 2023-06-14 18:01:15 +02:00
parent f594a54e07
commit 1cbe1a6c1e
2 changed files with 29 additions and 0 deletions

3
contrib/git-hook-post-checkout Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
# Git pre-checkout hook restoring permissions and ownerships.
mtree -u < .mtree

26
contrib/git-hook-pre-commit Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
# Git pre-commit hook storing permissions and ownerships.
mtreeignore=$(mktemp --suffix mtree)
mtree_exclude() {
echo .git
# Get ignored files from git https://stackoverflow.com/a/467053
find . -not -path './.git/*' | git check-ignore --stdin
}
# In case .mtree doens't exists yet, we still want it in the specification
# to be generated.
if [ -f .mtree ]; then
touch .mtree
fi
mtree_exclude > "$mtreeignore"
trap 'rm --force "$mtreeignore"' EXIT
mtree -x -c \
-p . \
-k uname,gname,mode \
-X "$mtreeignore" > .mtree
git add .mtree