setup.sh: checks if git directory is dirty before bothering user with potentially scary question
This commit is contained in:
parent
300e9acd37
commit
330461cf1e
36
setup.sh
36
setup.sh
@ -191,25 +191,37 @@ function update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Reset Develop or Stable branch
|
# Reset Develop or Stable branch
|
||||||
|
function check_git_changes() {
|
||||||
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
echo "No changes in git directory"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "Changes in git directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
function reset() {
|
function reset() {
|
||||||
echo_block "Resetting branch and virtual env"
|
echo_block "Resetting branch and virtual env"
|
||||||
|
|
||||||
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* stable") ]
|
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* stable") ]
|
||||||
then
|
then
|
||||||
|
if check_git_changes; then
|
||||||
|
read -p "Keep your local changes? (Otherwise will remove all changes you made!) [Y/n]? "
|
||||||
|
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
|
|
||||||
read -p "Reset git branch? (This will remove all changes you made!) [y/N]? "
|
git fetch -a
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
|
|
||||||
git fetch -a
|
if [ "1" == $(git branch -vv | grep -c "* develop") ]
|
||||||
|
then
|
||||||
if [ "1" == $(git branch -vv | grep -c "* develop") ]
|
echo "- Hard resetting of 'develop' branch."
|
||||||
then
|
git reset --hard origin/develop
|
||||||
echo "- Hard resetting of 'develop' branch."
|
elif [ "1" == $(git branch -vv | grep -c "* stable") ]
|
||||||
git reset --hard origin/develop
|
then
|
||||||
elif [ "1" == $(git branch -vv | grep -c "* stable") ]
|
echo "- Hard resetting of 'stable' branch."
|
||||||
then
|
git reset --hard origin/stable
|
||||||
echo "- Hard resetting of 'stable' branch."
|
fi
|
||||||
git reset --hard origin/stable
|
else
|
||||||
|
echo "Reset ignored because you are not on 'stable' or 'develop'."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user