From 8c18426d283545323d73d96145f18ec3255695d8 Mon Sep 17 00:00:00 2001 From: Martin Lablans Date: Fri, 4 Nov 2022 16:12:08 +0100 Subject: [PATCH] Move warning up --- lib/update-bridgehead.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index a62f7fa..69b3887 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -36,6 +36,11 @@ CHANGES="" git_updated="false" for DIR in /etc/bridgehead $(pwd); do log "INFO" "Checking for updates to git repo $DIR ..." + OUT="$(git -C $DIR status --porcelain)" + if [ -n "$OUT" ]; then + log WARN "The working directory $DIR is modified. Changed files: $OUT" + report_error 1 "The working directory $DIR is modified. Changed files: $OUT" + fi if [ "$(git -C $DIR config --get credential.helper)" != "$CREDHELPER" ]; then log "INFO" "Configuring repo to use bridgehead git credential helper." git -C $DIR config credential.helper "$CREDHELPER" @@ -51,10 +56,6 @@ for DIR in /etc/bridgehead $(pwd); do if [ $? -ne 0 ]; then report_error 1 "Unable to update git $DIR: $OUT" fi - OUT="$(git -C $DIR status --porcelain)" - if [ -n "$OUT" ]; then - report_error 1 "The workingdirectory in $DIR is modified. Following files are changed: $OUT" - fi new_git_hash="$(git -C $DIR rev-parse --verify HEAD)" if [ "$old_git_hash" != "$new_git_hash" ]; then