This repository was archived by the owner on May 7, 2024. It is now read-only.
Add Git pre-commit hook to abort commit with unencrypted files #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
pre-commit script and instead of clobbering it,
save the script to the working directory and
print a message asking the user to install it
instead of deleting and tell the user we have
done so, to avoid deleting a script the user
might have customised.