Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ahorn/git-hooks-for-ansible-encryption
1 result
Show changes
Commits on Source (3)
......@@ -20,7 +20,6 @@ verbose() {
fi
}
# function to activate the virtual environment
activate () {
. .git/hooks/.venv/bin/activate
}
......@@ -41,7 +40,7 @@ isEncrypted() {
fi
}
# Read patterns from the patterns file
# Read patterns from the .patterns file
patterns=$(<$patternsFile)
# activte the python virtual environment
......@@ -55,6 +54,14 @@ for file in $files; do
echo "🡢 $file"
done
# get staged files
stagedFiles=$(git diff --name-only --staged)
echo
echo -e "${blue}staged files:${clear}"
for file in $stagedFiles; do
echo "🡢 $file"
done
# start encrypting the files
echo
echo -e "${blue}encrypting files:${clear}"
......@@ -69,6 +76,11 @@ for file in $files; do
if ansible-vault encrypt ${file} --vault-password-file ./.git/hooks/getPassword.sh > /dev/null 2>&1; then
echo -ne "${green}${clear}"
# only add the encrypted file if it was already staged
if echo "$stagedFiles" | grep -Fxq "$file"; then
git add $file
fi
else
echo -ne "${red}🮽 ${clear}"
encryptionError=true
......
......@@ -30,8 +30,19 @@ This git hooks for `pre-commit` and `post-commit` (and optionally `post-checkout
Create a file called `.files-for-encryption` in you gits root directory and specify with files to encrypt. You can use any pattern supported by `pathspec` to specify files or folders. It implements the same matching algorithm like gitignore files. Only difference here is that you specify which files to encrypt instead of which to ignore.
### Example
```
test-file-matching.txt
test-folder-matching/*
!test-folder-matching/test-file-not-matching-in-folder.txt
```
\ No newline at end of file
```
## Troubleshooting / Known Issues
### Decrypt files manually
If you for some reason stuck in a state with encrypted files you can run `./.git/hooks/post-commit` manually to decrypt your files again.
### Interactive Mode / Partial Commits
Partial commits of encrypted files are currently not supported.
\ No newline at end of file