Skip to content

Commit 4fb7da4

Browse files
ehellbarsawenzel
authored andcommitted
protection against corrupt O2DPG repository during topology generation
1 parent 15049b0 commit 4fb7da4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

DATA/tools/epn/gen_topo_o2dpg.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,21 @@ while true; do
8282
break
8383
fi
8484
fi
85-
if [[ ! -d O2DPG ]]; then git clone https://github.com/AliceO2Group/O2DPG.git 1>&2 || { echo O2DPG checkout failed 1>&2; exit 1; }; fi
86-
cd O2DPG
85+
for CHECKOUTATTEMPT in 1 2; do
86+
if [[ ! -d O2DPG ]]; then git clone https://github.com/AliceO2Group/O2DPG.git 1>&2 || { echo O2DPG checkout failed 1>&2; exit 1; }; fi
87+
cd O2DPG
88+
rm -f DATA/core_dump_*
89+
git reset --hard HEAD &> /dev/null && git clean -d -f &> /dev/null && break
90+
[[ $CHECKOUTATTEMPT -eq 2 ]] && { echo git reset error 1>&2; exit 1; }
91+
echo "Clean-up of O2DPG repository failed. Removing repository and cloning it from scratch" 1>&2
92+
cd $GEN_TOPO_WORKDIR || { echo Cannot enter work dir 1>&2; exit 1; }
93+
rm -rf O2DPG
94+
done
8795
git checkout $GEN_TOPO_SOURCE &> /dev/null
8896
if [[ $? != 0 ]]; then
8997
git fetch --tags origin 1>&2 || { echo Repository update failed 1>&2; exit 1; }
9098
git checkout $GEN_TOPO_SOURCE &> /dev/null || { echo commit does not exist 1>&2; exit 1; }
9199
fi
92-
git reset --hard $GEN_TOPO_SOURCE &> /dev/null || { echo git reset error 1>&2; exit 1; }
93-
rm -f DATA/core_dump_*
94100
# At a tag, or a detached non-dirty commit, but not on a branch
95101
if ! git describe --exact-match --tags HEAD &> /dev/null && ( git symbolic-ref -q HEAD &> /dev/null || ! git diff-index --quiet HEAD &> /dev/null ); then
96102
unset GEN_TOPO_CACHEABLE

0 commit comments

Comments
 (0)