From 1cbe1a6c1edd2142395c500cc7ed859d1cb990ad Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Wed, 14 Jun 2023 18:01:15 +0200 Subject: [PATCH] Ajout hooks git de gestion de droits --- contrib/git-hook-post-checkout | 3 +++ contrib/git-hook-pre-commit | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 contrib/git-hook-post-checkout create mode 100755 contrib/git-hook-pre-commit diff --git a/contrib/git-hook-post-checkout b/contrib/git-hook-post-checkout new file mode 100755 index 0000000..6a15421 --- /dev/null +++ b/contrib/git-hook-post-checkout @@ -0,0 +1,3 @@ +#!/bin/sh +# Git pre-checkout hook restoring permissions and ownerships. +mtree -u < .mtree diff --git a/contrib/git-hook-pre-commit b/contrib/git-hook-pre-commit new file mode 100755 index 0000000..fca54ce --- /dev/null +++ b/contrib/git-hook-pre-commit @@ -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