From e49e0c2d10236692124cf4d98c570bbb504e6d66 Mon Sep 17 00:00:00 2001 From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de> Date: Fri, 19 Apr 2024 15:22:02 +0200 Subject: [PATCH] [mCBM 2024] add script to rebase cbmroot if mcbm Geo and Pars repo versions are used --- macro/beamtime/mcbm2024/README_GeoPar.md | 17 ++++++- macro/beamtime/mcbm2024/rebase_cbmroot.sh | 55 +++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 macro/beamtime/mcbm2024/rebase_cbmroot.sh diff --git a/macro/beamtime/mcbm2024/README_GeoPar.md b/macro/beamtime/mcbm2024/README_GeoPar.md index 73a78dec50..54ed10a454 100644 --- a/macro/beamtime/mcbm2024/README_GeoPar.md +++ b/macro/beamtime/mcbm2024/README_GeoPar.md @@ -8,7 +8,18 @@ ``` ./macro/beamtime/mcbm2024/switch_geo_par.sh ``` -1. +1. Rebasing Cbmroot + 1. Commit **and push** any local files/changes if you were in "mCBM mode" and did local changes in either the + geometry or parameters folders. Otherwise the rebase script will not do anything or they + 1. Execute the following script. \ + It relies on the presence of a remote pointing to the offical version (e.g. `origin` or `upstream`) and may ask + for some login information when fetching the latest changes depending on your remote definition. + ``` + ./macro/beamtime/mcbm2024/rebase_cbmroot.sh + ``` + 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!!! # CAVEATS @@ -23,6 +34,10 @@ versions" \ => Switching to another branch or a different detached commit than the "official version" will confuse them \ => This in turn has high chances to lead to broken copies of the `geometry` and/or `parameters` folders +1. **All these scripts apart from the one to commit changes will work only on clean copies!!!** \ + => local changes have to be either committed or deleted/reverted before using them!!! \ + => This also means that the scripts will all switch to the latest remote version. So doing "mcbm > official > mcbm" + may lead to a different commit! And local commits which are not yet pushed may be lost! 1. Space needed: - around `100 MB` for geometries - around `1.6 GB` for parameters diff --git a/macro/beamtime/mcbm2024/rebase_cbmroot.sh b/macro/beamtime/mcbm2024/rebase_cbmroot.sh new file mode 100755 index 0000000000..b2a2201cef --- /dev/null +++ b/macro/beamtime/mcbm2024/rebase_cbmroot.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only +# First commited by Pierre-Alain Loizeau + +WAS_MCBM_MODE=0 +START_DIR=$PWD + +# I: switch of branch/commit. Done only after all checks to avoid Geometry and Parameter folder going out of sync +# (one in "Official detached commit" and the other on "mCBM repo HEAD" mode) +# 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 already in official version, no need to switch back" +else + WAS_MCBM_MODE=1 + if ! ${VMCWORKDIR}/macro/beamtime/mcbm2024/switch_geo_par.sh; then + echo "Failed switching the geometry and parameters folders back to the official version, stopping there" + exit 1 + fi +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 already in official version, no need to switch back" +else + echo "Check on geometry folder should have already reverted the parameters one but still in mCBM mode" + echo "Please check your local folders with git status, your copy may be brocken/have folders out of sync" + exit 2 +fi + +cd $START_DIR + +# II: Cbmroot update in the standard way, +# => assumes in the source root folder but should anyway work anywhere in the tree +# => assumes that the official repo remote is already defined (e.g. either as origin or upstream) +official=$(git remote -v | grep fetch | grep "computing/cbmroot.git" | cut -f1) +if [ -n "${official}" ]; then + # Depending on your remote settings, the next command may ask for login/password information + git fetch ${official} + git rebase ${official}/master +else + echo "No remote found pointing to the official cbmroot repository/fork, rebase will not be done!!!!" +fi + +# III: revert geometry and parameters folders to mCBM mode if was the case before this call +if [[ 1 -eq ${WAS_MCBM_MODE} ]]; then + ${VMCWORKDIR}/macro/beamtime/mcbm2024/switch_geo_par.sh +fi + +exit 0 -- GitLab