From fbc7b1b2c12079fbb7fd55430e8d2a29c214be81 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 5 Jan 2010 13:30:01 -0200 Subject: Checking if a folder is inside a git repository --- lib/keyringer/functions | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib') diff --git a/lib/keyringer/functions b/lib/keyringer/functions index f0c4e0f..9c03000 100644 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -3,6 +3,7 @@ # Common functions. # +# Load a parameter from config function keyringer_config { if [ -z "$CONFIG" ]; then echo "Your have to set CONFIG variable in the code" @@ -15,10 +16,12 @@ function keyringer_config { fi } +# Return the list of recipients function keyringer_recipients { grep -v '^#' $1 | grep -v '^$' | awk '{ print "-r " $2 }' | xargs } +# Check if keyringer has a given action function keyringer_has_action { if [ -z "$ACTIONS" ]; then echo "Your have to set ACTIONS variable in the code" @@ -32,6 +35,7 @@ function keyringer_has_action { fi } +# Execute an action function keyringer_exec { # Setup action="$1" @@ -44,6 +48,27 @@ function keyringer_exec { fi } +# Return a filename with correct extension function keyringer_filename { echo `dirname $1`/`basename $1 .gpg`.gpg } + +# Check if a folder is inside a git repository +function keyringer_is_git { + if [ -z "$1" ]; then + false + elif [ ! -d "$1" ]; then + false + elif [ -d "$1/.git" ]; then + true + else + cwd="`pwd`" + cd $1 && git="`git status &> /dev/null`" && cd $cwd + + if [ "$git" != "128" ]; then + true + else + false + fi + fi +} -- cgit v1.2.3