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 (2)
/.venv/
......@@ -16,6 +16,8 @@ cyan='\033[0;36m'
clear='\033[0m'
patternsFile=.files-for-encryption
# get the used hooks path and remove the trailing slash
hooksPath=$((git config core.hooksPath || echo ".git/hooks/") | sed 's:/*$::')
VERBOSE=false
# Function to print verbose messages
......@@ -27,7 +29,7 @@ verbose() {
# function to activate the virtual environment
activate () {
. .git/hooks/.venv/bin/activate
. $hooksPath/.venv/bin/activate
}
# check for "$ANSIBLE_VAULT"
......@@ -53,7 +55,7 @@ patterns=$(<$patternsFile)
activate
# match the files for decryption
files=$(python .git/hooks/get-matched-files-for-encryption.py $patternsFile .)
files=$(python $hooksPath/get-matched-files-for-encryption.py $patternsFile .)
echo -e "${blue}files to decrypt:${clear}"
for file in $files; do
......@@ -72,7 +74,7 @@ for file in $files; do
continue
fi
if ansible-vault decrypt ${file} --vault-password-file ./.git/hooks/getPassword.sh > /dev/null 2>&1; then
if ansible-vault decrypt ${file} --vault-password-file ./$hooksPath/getPassword.sh > /dev/null 2>&1; then
echo -ne "${green}${clear}"
else
echo -ne "${red}🮽 ${clear}"
......
......@@ -12,6 +12,9 @@ clear='\033[0m'
patternsFile=.files-for-encryption
# get the used hooks path and remove the trailing slash
hooksPath=$((git config core.hooksPath || echo ".git/hooks/") | sed 's:/*$::')
VERBOSE=false
# Function to print verbose messages
verbose() {
......@@ -21,7 +24,7 @@ verbose() {
}
activate () {
. .git/hooks/.venv/bin/activate
. $hooksPath/.venv/bin/activate
}
# check for "$ANSIBLE_VAULT"
......@@ -47,7 +50,7 @@ patterns=$(<$patternsFile)
activate
# match the files for encryption
files=$(python .git/hooks/get-matched-files-for-encryption.py $patternsFile .)
files=$(python $hooksPath/get-matched-files-for-encryption.py $patternsFile .)
echo -e "${blue}files to encrypt:${clear}"
for file in $files; do
......@@ -74,7 +77,7 @@ for file in $files; do
continue
fi
if ansible-vault encrypt ${file} --vault-password-file ./.git/hooks/getPassword.sh > /dev/null 2>&1; then
if ansible-vault encrypt ${file} --vault-password-file ./$hooksPath/getPassword.sh > /dev/null 2>&1; then
echo -ne "${green}${clear}"
# only add the encrypted file if it was already staged
......