Skip to content
Snippets Groups Projects
Commit 12a85ec5 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau
Browse files

[mCBM 2024] add script to update/rebase mcbm Geo and Pars repo versions in local folders

parent e49e0c2d
No related branches found
No related tags found
1 merge request!1765Scripts to use mCBM 2024 separate forks
......@@ -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
......
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment