Pre-commit hook to avoid accidentally adding unencrypted files
- Lingua principale
- C++
- Stelle
- 9.9k
- Fork
- 544
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
This should not happen very often, but for users who do not read the doc, or someone who has locked their repository a long time ago and forgot about it, it could be useful to try and prevent this situation:
```
$ git crypt lock # a long time ago... then forgotten
$ echo "secret.file filter=git-crypt diff=git-crypt" >> .gitattributes
$ echo "secret" > secret.file
$ git status # forgot to check using git-crypt status
$ git add secret.file
$ git commit -m "added secret file"
$ git push
```
`secret.file` has been added to `.gitattributes`, but the repository was locked so the person ended up adding it unencrypted.
`git-crypt status` already displays a huge warning in this situation, but it remains possible to make a mistake when it is not run. May I suggest adding to the documentation an example of a pre-commit hook such as this:
```
#!/bin/sh
#pre-commit
git-crypt status | grep "*** WARNING"; test $? -eq 1
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.