diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5837df7b0a8919fdf0cdc0970df591df10c88a8d..19ca9411e0d2b986df9408afebf7ed82b6e071a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -65,8 +65,12 @@ FormatCheck: refs: - merge_requests variables: - - $CI_MERGE_REQUEST_PROJECT_PATH == "computing/cbmroot" + - $CI_MERGE_REQUEST_PROJECT_PATH == "computing/cbmroot" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" script: + # Get the upstream repository manually. I did not find any other way to have it for + # comparisson + - scripts/connect_upstream_repo.sh $CI_MERGE_REQUEST_PROJECT_URL + - git fetch upstream - echo "export FAIRSOFT_VERSION=jun19p1" > env.sh - echo "export FAIRROOT_VERSION=v18.2.0" >> env.sh - echo "export SIMPATH=/cvmfs/fairroot.gsi.de/fairsoft/\${FAIRSOFT_VERSION}" >> env.sh @@ -75,6 +79,7 @@ FormatCheck: - echo "export SOURCEDIR=$PWD" >> env.sh - echo "export PATH=/cvmfs/fairroot.gsi.de/clang-format-8.0.1:\$SIMPATH/bin:$PATH:/cvmfs/it.gsi.de/compiler/llvm/6.0.1/bin/" >> env.sh - echo "export LABEL=format-check_MR-\${CI_MERGE_REQUEST_IID}" >> env.sh + - echo "export FAIRROOT_FORMAT_BASE=upstream/\${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" >> env.sh - . ./env.sh && ctest -S cmake/scripts/checkformat.cmake -VV CbmRoot_Merge: @@ -85,7 +90,7 @@ CbmRoot_Merge: refs: - merge_requests variables: - - $CI_MERGE_REQUEST_PROJECT_PATH == "computing/cbmroot" + - $CI_MERGE_REQUEST_PROJECT_PATH == "computing/cbmroot" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" script: - echo $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH - echo $CI_MERGE_REQUEST_PROJECT_PATH diff --git a/cmake/scripts/check-format.sh b/cmake/scripts/check-format.sh index 73b8a163521f601a4ababc9b4546d2f8f764275a..ffec2cf57d00a3c40a06181ab0601e4ac0de339a 100755 --- a/cmake/scripts/check-format.sh +++ b/cmake/scripts/check-format.sh @@ -14,4 +14,3 @@ else echo "$RESULT" exit 1 fi - diff --git a/scripts/connect_upstream_repo.sh b/scripts/connect_upstream_repo.sh new file mode 100755 index 0000000000000000000000000000000000000000..c4781edcca3ea65a624fc90d0874ff86ac0cb20e --- /dev/null +++ b/scripts/connect_upstream_repo.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +upstream_repo=$1 + +bla=$(git remote -v | grep upstream) +if [ $? -eq 0 ]; then + echo "Remote link upstream already exist" + bla=$(git remote -v | grep upstream | grep $upstream_repo) + if [ $? -eq 0 ]; then + echo "Remote link upstream already exist and points to the correct repo" + # dont do anything + else + echo "Remote link upstream already exist and points to the wrong repo" + git remote rm upstream + git remote add upstream $upstream_repo + fi +else + echo "Remote repo has to be connected" + git remote add upstream $upstream_repo +fi