[commit: ghc] wip/cleanup-lint: gitlab-ci: Avoid relying on target branch name (30f09be)

git at git.haskell.org git at git.haskell.org
Sat Mar 23 00:00:57 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/cleanup-lint
Link       : http://ghc.haskell.org/trac/ghc/changeset/30f09be6f081e373277c35425fc0fca4d73fc699/ghc

>---------------------------------------------------------------

commit 30f09be6f081e373277c35425fc0fca4d73fc699
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Fri Mar 22 19:34:05 2019 -0400

    gitlab-ci: Avoid relying on target branch name
    
    When computing the merge base for the linters don't rely on the target
    branch name as this is rather fragile. Instead we can just use
    `$CI_MERGE_REQUEST_TARGET_BRANCH_SHA`.


>---------------------------------------------------------------

30f09be6f081e373277c35425fc0fca4d73fc699
 .gitlab-ci.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f22354a..4a480ae 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -47,9 +47,10 @@ ghc-linters:
   stage: lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
-    - git fetch origin
-    - base="$(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA)"
-    - "echo Merge base $base"
+    - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_SHA
+    - "echo Target branch SHA: $CI_MERGE_REQUEST_TARGET_BRANCH_SHA"
+    - base="$(git merge-base $CI_MERGE_REQUEST_TARGET_BRANCH_SHA $CI_COMMIT_SHA)"
+    - "echo Merge base: $base"
     #    - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
     - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
     - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA



More information about the ghc-commits mailing list