From 1c58fc1a2ffadb4f03979e291e05b4a1fd6295de Mon Sep 17 00:00:00 2001 From: materus Date: Thu, 21 Mar 2024 23:36:48 +0100 Subject: [PATCH] crypt.sh: check git only before encrypt/decrypt --- crypt.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crypt.sh b/crypt.sh index 852519b..e260505 100755 --- a/crypt.sh +++ b/crypt.sh @@ -9,12 +9,13 @@ echo "Use \"unlock\" /path/to/key to unlock with symmetric key" echo "Use \"lock\": to lock repository" exit fi - +check_git () { if [ "$(git status --porcelain)" ]; then echo "Working directory not clean." echo "Please commit your changes or 'git stash' them before running this script" exit 1 fi +} create_decrypt () { touch decrypted @@ -30,12 +31,14 @@ delete_decrypt () { if [ $# = 1 ]; then if [ $1 = "unlock" ]; then + check_git git-crypt unlock create_decrypt exit fi if [ $1 = "lock" ]; then + check_git delete_decrypt git-crypt lock exit