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' ...@@ -16,6 +16,8 @@ cyan='\033[0;36m'
clear='\033[0m' clear='\033[0m'
patternsFile=.files-for-encryption 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 VERBOSE=false
# Function to print verbose messages # Function to print verbose messages
...@@ -27,7 +29,7 @@ verbose() { ...@@ -27,7 +29,7 @@ verbose() {
# function to activate the virtual environment # function to activate the virtual environment
activate () { activate () {
. .git/hooks/.venv/bin/activate . $hooksPath/.venv/bin/activate
} }
# check for "$ANSIBLE_VAULT" # check for "$ANSIBLE_VAULT"
...@@ -53,7 +55,7 @@ patterns=$(<$patternsFile) ...@@ -53,7 +55,7 @@ patterns=$(<$patternsFile)
activate activate
# match the files for decryption # 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}" echo -e "${blue}files to decrypt:${clear}"
for file in $files; do for file in $files; do
...@@ -72,7 +74,7 @@ for file in $files; do ...@@ -72,7 +74,7 @@ for file in $files; do
continue continue
fi 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}" echo -ne "${green}${clear}"
else else
echo -ne "${red}🮽 ${clear}" echo -ne "${red}🮽 ${clear}"
......
...@@ -12,6 +12,9 @@ clear='\033[0m' ...@@ -12,6 +12,9 @@ clear='\033[0m'
patternsFile=.files-for-encryption 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 VERBOSE=false
# Function to print verbose messages # Function to print verbose messages
verbose() { verbose() {
...@@ -21,7 +24,7 @@ verbose() { ...@@ -21,7 +24,7 @@ verbose() {
} }
activate () { activate () {
. .git/hooks/.venv/bin/activate . $hooksPath/.venv/bin/activate
} }
# check for "$ANSIBLE_VAULT" # check for "$ANSIBLE_VAULT"
...@@ -47,7 +50,7 @@ patterns=$(<$patternsFile) ...@@ -47,7 +50,7 @@ patterns=$(<$patternsFile)
activate activate
# match the files for encryption # 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}" echo -e "${blue}files to encrypt:${clear}"
for file in $files; do for file in $files; do
...@@ -74,7 +77,7 @@ for file in $files; do ...@@ -74,7 +77,7 @@ for file in $files; do
continue continue
fi 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}" echo -ne "${green}${clear}"
# only add the encrypted file if it was already staged # only add the encrypted file if it was already staged
......