File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ - id : git-crypt
2+ name : Avoid to commit unencrypted files
3+ description : Pre-commit hook to avoid accidentally adding unencrypted files with git-crypt
4+ entry : check-git-crypt.sh
5+ language : script
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # See <https://gist.github.com/Falkor/848c82daa63710b6c132bb42029b30ef>
4+ # Pre-commit hook to avoid accidentally adding unencrypted files with [git-crypt](https://www.agwa.name/projects/git-crypt/)
5+
6+ if [ -d .git-crypt ]; then
7+ STAGED_FILES=$( git diff --cached --name-status | awk ' $1 != "D" { print $2 }' | xargs echo)
8+ if [ -n " ${STAGED_FILES} " ]; then
9+ git-crypt status ${STAGED_FILES} & > /dev/null
10+ if [[ $? -ne 0 ]]; then
11+ git-crypt status -e ${STAGED_FILES}
12+ echo ' /!\ You should have first unlocked your repository BEFORE staging the above file(s)'
13+ echo ' /!\ Proceed now as follows:'
14+ echo -e " \t git unstage ${STAGED_FILES} "
15+ echo -e " \t git crypt unlock"
16+ echo -e " \t git add ${STAGED_FILES} "
17+ exit 1
18+ fi
19+ fi
20+ fi
You can’t perform that action at this time.
0 commit comments