AGWA / AGWA/git-crypt

Pre-commit hook to avoid accidentally adding unencrypted files

Open
#45 11 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
9.9k
Forks
544
PR merge metrics
No merged PRs in 30d

Description

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.