-
Notifications
You must be signed in to change notification settings - Fork 107
Add Git pre-commit hook to abort commit with unencrypted files (#31) #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This branch is a mess of merges and spurious commits sorry, I should have cherry-picked instead of merging the original v1 changes. If/when this is merged to master the whole lot should be squashed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a reasonable implementation for that safety check...thank you for submitting it. Let me know once the merge conflicts have been handled, and I'd be glad to give it another look over.
plain text files staged by tools that do not respect the .gitattribute | ||
filters Transcrypt needs to do its job. | ||
|
||
- Add functional tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion as the other PR, but I think we could use a legit CHANGELOG.
On transcrypt init, add a pre-commit Git hook script to check crypt files and abort a commit if there is an un-encrypted file staged in the index that would otherwise be committed in plaintext. This is a safety mechanism to prevent accidental commits of plain text files that have been staged by tools that do not respect or run the .gitattribute filters that Transcrypt needs to do its job. A pre-commit-crypt file is now always installed in the Git hooks directory, but is only "activated" if there is no existing pre-commit hook file. On uninstall the pre-commit file is removed only if it is definitely safe to do so because the file exactly matches the hook file put in place by Transcrypt, proving the user has made no manual changes.
c44d473
to
1e4aecf
Compare
Hi @elasticdog I have rebased and cleaned up the commits in this PR to make more sense, I think this is ready for review. Regarding the change log I agree a CHANGELOG file would be best. This is probably something to tackle after dealing with this PR and #76 since the new changeling file should probably include all changes, not just changes specific to these PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
On init, add a pre-commit Git hook script to check Transcrypt-managed files and abort a commit if there is an un-encrypted file staged in the index that would otherwise be committed in plaintext. See related issue #31
This is a safety mechanism to prevent accidental commits of plain text files that have been staged by tools that do not respect or run the .gitattribute filters that Transcrypt needs to do its job.
On commit failure, the error message says how to re-stage the file using Git on the command line:
Because Git hooks work with single scripts only it is difficult to cleanly install and uninstall hook scripts, especially if the user already has a pre-commit hook script in place.
To handle this situation cleanly if naively