gitlab-ci: Compute merge base against remote tracking branch
authorBen Gamari <ben@smart-cactus.org>
Fri, 22 Mar 2019 22:49:34 +0000 (18:49 -0400)
committerBen Gamari <ben@smart-cactus.org>
Fri, 22 Mar 2019 22:49:34 +0000 (18:49 -0400)
Previously we would use the local branch with the name
`$CI_MERGE_REQUEST_TARGET_BRANCH_NAME` to compute the merge base when
linting. However, this branch isn't necessarily up-to-date. We should
rather use `origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME`.

.gitlab-ci.yml

index 01fcc6a..f22354a 100644 (file)
@@ -48,7 +48,7 @@ ghc-linters:
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
     - git fetch origin
-    - base="$(git merge-base $CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA)"
+    - base="$(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $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)