set -e
# parameter: $1: git tag to build
-git clone https://github.com/wagner-tech/kivitendo-erp
-cd kivitendo-erp
-git checkout $1
+# options: -g <alternative repository>
+
+#repos="https://github.com/wagner-tech"
+#if getopts "g:" opt; then
+# repos=$OPTARG
+# shift 2
+#fi
+#
+#if [ -e kivitendo-erp ]
+#then
+# pushd kivitendo-erp >/dev/null
+ #branch=$(git rev-parse --abbrev-ref HEAD)
+ #git pull origin $branch
+#else
+# git clone $repos/kivitendo-erp
+# pushd kivitendo-erp >/dev/null
+#fi
+# git checkout $1
+#popd >/dev/null
+
+# alternativer Versuch: Es wird das lokale Repository geklont:
+
+cwd=$(pwd)
+git clone ${cwd%/build/src}
+pushd kivitendo-erp >/dev/null
+ git checkout $1
+popd >/dev/null
+