Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cbmroot
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computing
cbmroot
Commits
7957effc
Commit
7957effc
authored
11 months ago
by
Pierre-Alain Loizeau
Browse files
Options
Downloads
Patches
Plain Diff
[mCBM 2024] add script to safely push mcbm Geo and Pars local changes to remote
parent
12a85ec5
No related branches found
No related tags found
1 merge request
!1765
Scripts to use mCBM 2024 separate forks
Pipeline
#28885
passed
11 months ago
Stage: package
Stage: verify
Stage: documentation
Stage: deploy
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
macro/beamtime/mcbm2024/README_GeoPar.md
+9
-0
9 additions, 0 deletions
macro/beamtime/mcbm2024/README_GeoPar.md
macro/beamtime/mcbm2024/commit_push_geo_par.sh
+109
-0
109 additions, 0 deletions
macro/beamtime/mcbm2024/commit_push_geo_par.sh
with
118 additions
and
0 deletions
macro/beamtime/mcbm2024/README_GeoPar.md
+
9
−
0
View file @
7957effc
...
...
@@ -27,6 +27,15 @@
=> 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).
1.
Commiting changes
-
Either do it by hand in the geometry/parameters folders (they are independent git clones)
-
Or use the following script. This will take care of making a single commit for each of the two folders,
prepare them for a fast-forward push and push them. You will probably be asked for some login/password.
```
./macro/beamtime/mcbm2024/commit_push_geo_par.sh
```
=> This script was not 100% tested as the original author (@p.-a.loizeau) did not have local changes to push
\
=>
**But all individual commands were tested and the scripts was checked with a semantics checker!**
# CAVEATS
...
...
This diff is collapsed.
Click to expand it.
macro/beamtime/mcbm2024/commit_push_geo_par.sh
0 → 100755
+
109
−
0
View file @
7957effc
#!/bin/bash
# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Pierre-Alain Loizeau
check_author_info
()
{
name_set
=
$(
git config
-l
|
grep
-c
"user.name"
)
email_set
=
$(
git config
-l
|
grep
-c
"user.email"
)
author_ok
=
0
if
[[
1
-ne
${
name_set
}
]]
;
then
echo
"Error: user.name not set in git config (neither globally no locally)"
author_ok
=
1
fi
if
[[
1
-ne
${
email_set
}
]]
;
then
echo
"Error: user.email not set in git config (neither globally no locally)"
author_ok
=
$((
author_ok+2
))
fi
return
${
author_ok
}
}
Help
()
{
# Non-aligned raw text due to escaped characters!
echo
"Allowed input parameters for this script are:"
echo
" -h | --help this help"
echo
" -f | --folder [
\"
geometry
\"
,
\"
parameters
\"
] folder to push (and commitbefore if needed) (mandatory)"
echo
" -m | --message
\"
<commit message>
\"
commit message in case some not-yet committed local"
echo
" files/changes are present in the folder (optional)"
}
while
[
$#
-gt
0
]
;
do
case
"
$1
"
in
-h
|
--help
)
Help
;
exit
0
;;
-f
|
--folder
)
folder
=
"
$2
"
;
shift
;;
-m
|
--message
)
message
=
"
$2
"
;
shift
;;
\?
)
# Invalid option
echo
"Error: Invalid option"
Help
exit
1
;;
esac
shift
done
if
[
-z
"
${
folder
}
"
]
;
then
echo
"Missing mandatory parameter: folder to commit/push"
Help
exit
1
fi
if
[[
!
"
${
folder
}
"
=
~ ^
(
geometry|parameters
)
$
]]
;
then
echo
"Invalid value for the folder parameter:
${
folder
}
"
echo
"It has to be either
\"
geometry
\"
or
\"
parameters
\"
"
Help
exit
1
fi
# I: pre-checks, this part should be read-only actions in terms of the current files (changes only in .git folders)!
# I-1) Go to folder
cd
${
VMCWORKDIR
}
/
${
folder
}
# I-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
"
${
folder
}
folder is in official version, cannot update to get latest mCBM changes, stopping there"
exit
2
fi
# I-3) Check if some local changes are present, in which case make a commit with them if commit message was provided
if
[[
0
-ne
$(
git status
--porcelain
|
wc
-l
)
]]
;
then
echo
"Local changes found in the geometry folder."
if
[
-n
"
${
message
}
"
]
;
then
echo
"=> Commit message provided, trying to make a commit with all of them"
if
!
check_author_info
;
then
echo
"Author info missing, cannot make a proper commit"
exit
4
fi
git add
.
git commit
-m
"
${
message
}
"
else
echo
"=> no commit message provided, stopping there. Following files/changes are present"
git status
--short
Help
exit
3
fi
fi
# II: check that local history is compatible with remote version and push if ok
# II-1) fetch latest version of remote
git fetch mcbm
# II-2) rebase only this folder.
# FIXME ?: Could call the rebase script to avoid copy-paste, but then both folders would be rebased which may make
# to a deadlock if both have local changed?
if
!
git rebase mcbm/mcbm24_master
;
then
echo
"Rebasing the
${
folder
}
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
5
else
echo
"Now up to date with the mcbm remote version of the
${
folder
}
folder"
fi
# II-3) push without force or force-with-lease, no change to remote history allowed
git push
cd
${
START_DIR
}
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment