Commit 9e5b432f authored by Xueshan Feng's avatar Xueshan Feng
Browse files

Merge branch 'master' into 'master'

Unlock current repo  before unlock submodules

Move git-crypt unlock code to a function and unlock the current dir
before looping through submodules.

See merge request !1
parents 5b6111e7 a5d276ac
Loading
Loading
Loading
Loading
Loading
+21 −11
Original line number Diff line number Diff line
@@ -33,6 +33,22 @@ function verify_gpg_passphrase() {
  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
keyfile=${1:-''}
if [ -z $keyfile ];
@@ -43,6 +59,10 @@ else
  [ ! -f $keyfile ] && abort "unable to read $keyfile."
fi

# unlock current repo
do_unlock $keyfile

# unlock submodules
modules=$(git submodule status)
[ -z "$modules" ] && abort "No submodules"

@@ -57,17 +77,7 @@ do
    ( echo "Checking out $i master branch"
      cd $m
      git checkout master
      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
      do_unlock $keyfile
    )
  fi
done