Print base commit for source linters
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
index 840b26969ff65f77fbfc2d31ff9aa102441e632f..3ad8266efd3a99a7f2560870f40e7969ed435ef4 100644 (file)
@@ -55,7 +55,13 @@ clang-tidy:test:
     KUBERNETES_CPU_REQUEST: 2
     KUBERNETES_MEMORY_LIMIT: 4Gi
   script:
-    - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && git show -s --pretty=format:"%h" `git merge-base --fork-point FETCH_HEAD HEAD`)
+    - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+    - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
+    - if [[ "$REV" == "$HEAD_REV" ]] ; then
+        REV="HEAD~1" ;
+      fi
+    - echo "Revision used for branch point is $REV"
+    - git show -s $REV
     - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=$REV -B=$BUILD_DIR
     - grep -i "found code issues" clang-tidy.log | tee code-lint.txt || true
     - if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
@@ -81,6 +87,12 @@ clang-format:
     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
   script:
     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+    - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
+    - if [[ "$REV" == "$HEAD_REV" ]] ; then
+        REV="HEAD~1" ;
+      fi
+    - echo "Revision used for branch point is $REV"
+    - git show -s $REV
     - CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION admin/clang-format.sh check --rev=$REV --warnings=clang-format.log
     - grep -i "needs formatting" clang-format.log | tee formatting.txt || true
     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
@@ -104,6 +116,12 @@ copyright-check:
     KUBERNETES_MEMORY_LIMIT: 2Gi
   script:
     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+    - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
+    - if [[ "$REV" == "$HEAD_REV" ]] ; then
+        REV="HEAD~1" ;
+      fi
+    - echo "Revision used for branch point is $REV"
+    - git show -s $REV
     - admin/copyright.sh check --rev=$REV --warnings=copyright.log
     - grep -i "copyright year" copyright.log | tee years.log || true
     - grep -i "copyright header" copyright.log | tee headers.log || true