mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 04:05:36 +00:00
Push latest httpd git changes and any merge in main to the remote.
Check for error status after potential conflicts.
This commit is contained in:
+27
-8
@@ -23,12 +23,24 @@ sync_repo() {
|
||||
ssh -o "StrictHostKeyChecking=no" -o "ConnectTimeout=10" root@${IP} "cd ~ && sync-repo-and-execute-cmd.sh '${DIR}' '${COMMAND}' '${2}'";
|
||||
done;
|
||||
}
|
||||
check_conflict() {
|
||||
# $1: Return code of a command
|
||||
# $2: Error msg to use
|
||||
if [[ "$1" -ne 0 ]]; then
|
||||
echo "$2"
|
||||
echo "$2" | notify-operators "Merge issue for httpd config repo in checked-out workspace"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
merge_main_into_branch() {
|
||||
#$1 branch name. Assumes you are in the git repo.
|
||||
#$1 Branch name. Assumes you are in the git repo.
|
||||
git checkout "${1}"
|
||||
check_conflict "$?" "Conflict checking out ${1}"
|
||||
git pull
|
||||
echo "merging ${MAIN_BRANCH_NAME} into ${1}"
|
||||
check_conflict "$?" "Conflict pulling ${1}"
|
||||
echo "Merging ${MAIN_BRANCH_NAME} into ${1}"
|
||||
git merge ${MAIN_BRANCH_NAME}
|
||||
check_conflict "$?" "Conflict merging ${MAIN_BRANCH_NAME} into ${1}"
|
||||
git push
|
||||
}
|
||||
while read oldrev newrev refname; do # These vars are passed on stdin to this hook.
|
||||
@@ -46,14 +58,21 @@ while read oldrev newrev refname; do # These vars are passed on stdin to this
|
||||
cd ~
|
||||
unset GIT_DIR
|
||||
cd ${CHECKED_OUT_WORKSPACE_NAME}
|
||||
# get the latest main
|
||||
# Get the latest main
|
||||
git checkout ${MAIN_BRANCH_NAME}
|
||||
check_conflict "$?" "Uncommitted files in the working directory"
|
||||
git pull
|
||||
# get the latest diposable branch and merge in changes
|
||||
merge_main_into_branch "$DISPOSABLE_BRANCH_NAME"
|
||||
# get the latest central branch and merge in changes
|
||||
merge_main_into_branch "$CENTRAL_BRANCH_NAME"
|
||||
git checkout ${MAIN_BRANCH_NAME}
|
||||
if [[ "$(git rev-parse ${MAIN_BRANCH_NAME})" != "$(git rev-parse origin/${MAIN_BRANCH_NAME})" ]]; then
|
||||
echo "Merge induced by pull. Pushing latest changes in ${MAIN_BRANCH_NAME} to origin" # In case of a merge from diverging branches. This seems cyclic as we are pushing to the same branch, but should resolve, when "Everything up-to-date".
|
||||
git push
|
||||
else
|
||||
check_conflict "$?" "Merge conflict in main branch"
|
||||
# Get the latest diposable branch and merge in changes
|
||||
merge_main_into_branch "$DISPOSABLE_BRANCH_NAME"
|
||||
# Get the latest central branch and merge in changes
|
||||
merge_main_into_branch "$CENTRAL_BRANCH_NAME"
|
||||
git checkout ${MAIN_BRANCH_NAME}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user