summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux User <ziggys@alpine.my.domain>2018-07-14 14:49:42 -0400
committerLinux User <ziggys@alpine.my.domain>2018-07-14 14:49:42 -0400
commitc355bb0ebf91f027a70d1f6fb4260ee549ebadd1 (patch)
tree1474ad700aaebbda23e358b127512a0eff158ff7
parent0af28f05937ddeed385cd6fa1af4b6d63d527b45 (diff)
downloadsnippets-c355bb0ebf91f027a70d1f6fb4260ee549ebadd1.tar
snippets-c355bb0ebf91f027a70d1f6fb4260ee549ebadd1.zip
Check if pwd is git repo
-rwxr-xr-xbump-version.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/bump-version.sh b/bump-version.sh
index 0284612..5ffb5d9 100755
--- a/bump-version.sh
+++ b/bump-version.sh
@@ -8,7 +8,7 @@
# scriptinfo
SCRIPTNAME="${0##*/}"
SCRIPTNAME="${SCRIPTNAME%%.sh}"
-VERSION="0.0.2" # usage
+VERSION="0.0.3" # Check if pwd is git repo
AUTHOR="ziggys"
LICENSE="Public Domain"
@@ -57,6 +57,13 @@ printf "\\n/* Write a version description, save the file and close %s\\n \
&& DESCRIPTION="version ${NEXT}"
}
+isgit () {
+ git rev-parse > /dev/null
+ test "$?" -ne 0 \
+ && printf "Working directory is not a git repository, exiting..." \
+ && exit 0
+}
+
# obtain current version
TMPDIR="$(mktemp -d)"
VFILE="$2"
@@ -135,12 +142,14 @@ read -r CCOMMIT
case "${CCOMMIT}" in
y | yes | Y | YES | Yes )
+ isgit
printf "\\nAdding %s to stage and commiting changes" "${VFILE}"
git add "${VFILE}"
git commit -m "${DESCRIPTION}"
ISTAG="${NTAG}"
;;
a | all | A | ALL | All )
+ isgit
FILES="$(find . | grep -v "git" | sed 's/.\///g; 1 d')"
for file in $FILES; do
sed -i '/^VERSION=/ s/'"${CURRENT}"'/'"${NEXT}"'/' "${file}"