Ensure git reset --hard is realy desired

This commit is contained in:
Matthias 2019-08-07 21:45:58 +02:00
parent 831e708897
commit 7a47d81b7b

View File

@ -117,28 +117,33 @@ function reset() {
echo "----------------------------" echo "----------------------------"
echo "Reseting branch and virtual env" echo "Reseting branch and virtual env"
echo "----------------------------" echo "----------------------------"
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ] if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ]
then then
if [ -d ".env" ]; then
echo "- Delete your previous virtual env"
rm -rf .env
fi
git fetch -a read -p "Reset git branch? (This will remove all changes you made!) [y/N]? "
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ "1" == $(git branch -vv |grep -c "* develop") ] git fetch -a
then
echo "- Hard resetting of 'develop' branch." if [ "1" == $(git branch -vv |grep -c "* develop") ]
git reset --hard origin/develop then
elif [ "1" == $(git branch -vv |grep -c "* master") ] echo "- Hard resetting of 'develop' branch."
then git reset --hard origin/develop
echo "- Hard resetting of 'master' branch." elif [ "1" == $(git branch -vv |grep -c "* master") ]
git reset --hard origin/master then
echo "- Hard resetting of 'master' branch."
git reset --hard origin/master
fi
fi fi
else else
echo "Reset ignored because you are not on 'master' or 'develop'." echo "Reset ignored because you are not on 'master' or 'develop'."
fi fi
if [ -d ".env" ]; then
echo "- Delete your previous virtual env"
rm -rf .env
fi
echo echo
${PYTHON} -m venv .env ${PYTHON} -m venv .env
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then