Added Dev Mode option for git diff creation

This commit is contained in:
DerLinkman 2023-10-19 12:14:27 +02:00
parent 6c649debc9
commit 61e23b6b81

View File

@ -904,34 +904,38 @@ if [ "$CURRENT_REPO" != "$DEFAULT_REPO" ]; then
fi fi
fi fi
echo -e "\e[32mCommitting current status...\e[0m" if [ ! $DEV ]; then
[[ -z "$(git config user.name)" ]] && git config user.name moo echo -e "\e[32mCommitting current status...\e[0m"
[[ -z "$(git config user.email)" ]] && git config user.email moo@cow.moo [[ -z "$(git config user.name)" ]] && git config user.name moo
[[ ! -z $(git ls-files data/conf/rspamd/override.d/worker-controller-password.inc) ]] && git rm data/conf/rspamd/override.d/worker-controller-password.inc [[ -z "$(git config user.email)" ]] && git config user.email moo@cow.moo
git add -u [[ ! -z $(git ls-files data/conf/rspamd/override.d/worker-controller-password.inc) ]] && git rm data/conf/rspamd/override.d/worker-controller-password.inc
git commit -am "Before update on ${DATE}" > /dev/null git add -u
echo -e "\e[32mFetching updated code from remote...\e[0m" git commit -am "Before update on ${DATE}" > /dev/null
git fetch origin #${BRANCH} echo -e "\e[32mFetching updated code from remote...\e[0m"
echo -e "\e[32mMerging local with remote code (recursive, strategy: \"${MERGE_STRATEGY:-theirs}\", options: \"patience\"...\e[0m" git fetch origin #${BRANCH}
git config merge.defaultToUpstream true echo -e "\e[32mMerging local with remote code (recursive, strategy: \"${MERGE_STRATEGY:-theirs}\", options: \"patience\"...\e[0m"
git merge -X${MERGE_STRATEGY:-theirs} -Xpatience -m "After update on ${DATE}" git config merge.defaultToUpstream true
# Need to use a variable to not pass return codes of if checks git merge -X${MERGE_STRATEGY:-theirs} -Xpatience -m "After update on ${DATE}"
MERGE_RETURN=$? # Need to use a variable to not pass return codes of if checks
if [[ ${MERGE_RETURN} == 128 ]]; then MERGE_RETURN=$?
echo -e "\e[31m\nOh no, what happened?\n=> You most likely added files to your local mailcow instance that were now added to the official mailcow repository. Please move them to another location before updating mailcow.\e[0m" if [[ ${MERGE_RETURN} == 128 ]]; then
exit 1 echo -e "\e[31m\nOh no, what happened?\n=> You most likely added files to your local mailcow instance that were now added to the official mailcow repository. Please move them to another location before updating mailcow.\e[0m"
elif [[ ${MERGE_RETURN} == 1 ]]; then exit 1
echo -e "\e[93mPotenial conflict, trying to fix...\e[0m" elif [[ ${MERGE_RETURN} == 1 ]]; then
git status --porcelain | grep -E "UD|DU" | awk '{print $2}' | xargs rm -v echo -e "\e[93mPotenial conflict, trying to fix...\e[0m"
git add -A git status --porcelain | grep -E "UD|DU" | awk '{print $2}' | xargs rm -v
git commit -m "After update on ${DATE}" > /dev/null git add -A
git checkout . git commit -m "After update on ${DATE}" > /dev/null
echo -e "\e[32mRemoved and recreated files if necessary.\e[0m" git checkout .
elif [[ ${MERGE_RETURN} != 0 ]]; then echo -e "\e[32mRemoved and recreated files if necessary.\e[0m"
echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m" elif [[ ${MERGE_RETURN} != 0 ]]; then
echo echo -e "\e[31m\nOh no, something went wrong. Please check the error message above.\e[0m"
echo "Run $COMPOSE_COMMAND up -d to restart your stack without updates or try again after fixing the mentioned errors." echo
exit 1 echo "Run $COMPOSE_COMMAND up -d to restart your stack without updates or try again after fixing the mentioned errors."
exit 1
fi
elif [ $DEV ]; then
echo -e "\e[33mDEVELOPER MODE: Not creating a git diff and commiting it to prevent development stuff within a backup diff...\e[0m"
fi fi
echo -e "\e[32mFetching new images, if any...\e[0m" echo -e "\e[32mFetching new images, if any...\e[0m"