crypt.sh: check git only before encrypt/decrypt

This commit is contained in:
Mateusz Słodkowicz 2024-03-21 23:36:48 +01:00
parent cdc41c3934
commit 1c58fc1a2f
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
1 changed files with 4 additions and 1 deletions

View File

@ -9,12 +9,13 @@ echo "Use \"unlock\" /path/to/key to unlock with symmetric key"
echo "Use \"lock\": to lock repository" echo "Use \"lock\": to lock repository"
exit exit
fi fi
check_git () {
if [ "$(git status --porcelain)" ]; then if [ "$(git status --porcelain)" ]; then
echo "Working directory not clean." echo "Working directory not clean."
echo "Please commit your changes or 'git stash' them before running this script" echo "Please commit your changes or 'git stash' them before running this script"
exit 1 exit 1
fi fi
}
create_decrypt () { create_decrypt () {
touch decrypted touch decrypted
@ -30,12 +31,14 @@ delete_decrypt () {
if [ $# = 1 ]; then if [ $# = 1 ]; then
if [ $1 = "unlock" ]; then if [ $1 = "unlock" ]; then
check_git
git-crypt unlock git-crypt unlock
create_decrypt create_decrypt
exit exit
fi fi
if [ $1 = "lock" ]; then if [ $1 = "lock" ]; then
check_git
delete_decrypt delete_decrypt
git-crypt lock git-crypt lock
exit exit