Commit a5d276ac authored by Xu Wang's avatar Xu Wang
Browse files

fix git-crypt-unlock-all.sh, unlock current repo first before unlock submodules

parent 5b6111e7
Pipeline #315 skipped
...@@ -33,6 +33,22 @@ function verify_gpg_passphrase() { ...@@ -33,6 +33,22 @@ function verify_gpg_passphrase() {
done done
} }
function do_unlock() {
echo unlock $PWD
keyfile=$1
if [ ! -z $keyfile ];
then
git-crypt unlock $keyfile
else
expect <<EOF
spawn git-crypt unlock
expect "Enter passphrase:"
send "$passphrase\r";
expect eof
EOF
fi
}
# MAIN # MAIN
keyfile=${1:-''} keyfile=${1:-''}
if [ -z $keyfile ]; if [ -z $keyfile ];
...@@ -43,6 +59,10 @@ else ...@@ -43,6 +59,10 @@ else
[ ! -f $keyfile ] && abort "unable to read $keyfile." [ ! -f $keyfile ] && abort "unable to read $keyfile."
fi fi
# unlock current repo
do_unlock $keyfile
# unlock submodules
modules=$(git submodule status) modules=$(git submodule status)
[ -z "$modules" ] && abort "No submodules" [ -z "$modules" ] && abort "No submodules"
...@@ -57,17 +77,7 @@ do ...@@ -57,17 +77,7 @@ do
( echo "Checking out $i master branch" ( echo "Checking out $i master branch"
cd $m cd $m
git checkout master git checkout master
if [ ! -z $keyfile ]; do_unlock $keyfile
then
git-crypt unlock $keyfile
else
expect <<EOF
spawn git-crypt unlock
expect "Enter passphrase:"
send "$passphrase\r";
expect eof
EOF
fi
) )
fi fi
done done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment