AGWA / AGWA/git-crypt

Pre-commit hook to avoid accidentally adding unencrypted files

未關閉
#45 11 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
9.9k
分支
544
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。