diff --git a/macro/beamtime/mcbm2024/README_GeoPar.md b/macro/beamtime/mcbm2024/README_GeoPar.md index 54ed10a4545cc13d3e9760512fff9d8d4f1f9924..ff01db0495086fac43ca42ad6ce31816fa0823e4 100644 --- a/macro/beamtime/mcbm2024/README_GeoPar.md +++ b/macro/beamtime/mcbm2024/README_GeoPar.md @@ -20,6 +20,13 @@ Rebasing directly from the CLI without caring about the state of the geo and params folders will fail if they are in "mCBM mode" and may lead to a broken local copy \ => As soon as you start using the `switch_geo_par.sh` script in a Cbmroot copy, rebase it only with this script!!! +1. Updating/rebasing the mCBM versions of the geometry and parameters folders: just execute the following script + ``` + ./macro/beamtime/mcbm2024/update_geo_par.sh + ``` + => This will bring in the local copy the latest changes from the remote branch in the mCBM fork \ + => This will also ensure the local copies are compatible with a fast-forward push to the remote branch in the mCBM + fork (force-push or any git history changes are not allowed). # CAVEATS diff --git a/macro/beamtime/mcbm2024/update_geo_par.sh b/macro/beamtime/mcbm2024/update_geo_par.sh new file mode 100755 index 0000000000000000000000000000000000000000..99c59f95ed4dd71605e8b99738955ea282d5a8a7 --- /dev/null +++ b/macro/beamtime/mcbm2024/update_geo_par.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only +# First commited by Pierre-Alain Loizeau + +START_DIR=$PWD + +# I: pre-checks, this part should be read-only actions in terms of the current files (changes only in .git folders)! +# I-A: Geometry folder +# I-A-1) Go to folder +cd ${VMCWORKDIR}/geometry +# I-A-2) Check if current version is the Official detached commit or the mCBM repo HEAD +if [[ 1 -eq $(git status | grep -c "HEAD detached at") ]]; then + echo "Geometry folder is in official version, cannot update to get latest mCBM changes, stopping there" + exit 2 +fi +# I-A-3) Check if some local changes are present +if [[ 0 -ne $(git status --porcelain | wc -l) ]]; then + echo "Local changes found in the geometry folder." + echo "=> You need to remove them (or commit them if in mCBM mode) before updating" + git status --short + exit 3 +fi +# I-B: Parameters folder +# I-B-1) Go to folder +cd ${VMCWORKDIR}/parameters +# I-B-2) Check if current version is the Official detached commit or the mCBM repo HEAD +if [[ 1 -eq $(git status | grep -c "HEAD detached at") ]]; then + echo "Parameters folder is in official version, cannot update to get latest mCBM changes, stopping there" + exit 2 +fi +# I-B-3) Check if some local changes are present +if [[ 0 -ne $(git status --porcelain | wc -l) ]]; then + echo "Local changes found in the parameters folder." + echo "=> You need to remove them (or commit them if in mCBM mode) before updating" + git status --short + exit 3 +fi + +# II: Fetch latest changes and rebase the folder on them +# => straight-forward if no local commits +# => otherwise revert if conflicts found +# II-A: Geometry folder +# II-A-1) Go to folder +cd ${VMCWORKDIR}/geometry +# II-A-2) Fetch latest changes +git fetch mcbm +# II-A-3) Try to rebase, revert if this fails +if ! git rebase mcbm/mcbm24_master; then + echo "Rebasing the geometry folder failed, most probably due to local commits in conflict" + echo "Aborting (=reverting) the rebase!!!" + git rebase --abort + echo "Please rebase by hand in the geometry folder with the following commands:" + echo "git rebase mcbm/mcbm24_master # Will lead to a conflict" + echo "git rebase --continue # After each resolution of problems, for each conflicting commit" + echo "git rebase --abort # If not able to resolve the conflicts" + echo "=> If lost, please google \"git rebase resolve conflicts\" or ask other mcbm members" + exit 4 +else + echo "Now up to date with the mcbm remote version of the geometry folder" +fi +# II-A: Parameters folder +# II-A-1) Go to folder +cd ${VMCWORKDIR}/parameters +# II-A-2) Fetch latest changes +git fetch mcbm +# II-A-3) Try to rebase, revert if this fails +if ! git rebase mcbm/mcbm24_master; then + echo "Rebasing the parameters folder failed, most probably due to local commits in conflict" + echo "Aborting (=reverting) the rebase!!!" + git rebase --abort + echo "Please rebase by hand in the parameters folder with the following commands:" + echo "git rebase mcbm/mcbm24_master # Will lead to a conflict" + echo "git rebase --continue # After each resolution of problems, for each conflicting commit" + echo "git rebase --abort # If not able to resolve the conflicts" + echo "=> If lost, please google \"git rebase resolve conflicts\" or ask other mcbm members" + exit 4 +else + echo "Now up to date with the mcbm remote version of the parameters folder" +fi + +cd ${START_DIR} + +exit 0