From 10c1c3d6cd8e165501fb1471b5babfabd1be1eb1 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Fri, 29 Oct 2021 16:36:06 +0300 Subject: [PATCH] checkgit.sh: Added a check for local modifications (#3347) --- resources/checkgit.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/checkgit.sh b/resources/checkgit.sh index ef853bb6dd..49449ecdf2 100644 --- a/resources/checkgit.sh +++ b/resources/checkgit.sh @@ -8,6 +8,14 @@ trap "exit 1" ERR # and including any changes on main. # +# Check that local copy has no modifications +GIT_MODIFIED_FILES=$(git ls-files -dm 2> /dev/null); +GIT_STAGED_FILES=$(git diff --cached --name-only 2> /dev/null); +if [ "$GIT_MODIFIED_FILES" != "" -o "$GIT_STAGED_FILES" != "" ]; then + read -p "Git has local modifications. Continue? (y|N) " yn; + if [ "$yn" != "y" ]; then exit 1; fi; +fi; + # First fetch to ensure git is up to date. Fail-fast if this fails. git fetch; if [[ $? -ne 0 ]]; then exit 1; fi;