gitlab-ci: Fix submodule linter
authorBen Gamari <ben@smart-cactus.org>
Fri, 7 Jun 2019 15:14:07 +0000 (11:14 -0400)
committerBen Gamari <ben@well-typed.com>
Sat, 8 Jun 2019 17:34:18 +0000 (13:34 -0400)
The job script didn't even try to compute the base commit to lint with
respect to.

.gitlab-ci.yml

index fdb4174..a67d45e 100644 (file)
@@ -52,6 +52,8 @@ ghc-linters:
   stage: lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
+    # Note [Unshallow clone for linting]
+    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     # GitLab creates a shallow clone which means that we may not have the base
     # commit of the MR being tested (e.g. if the MR is quite old), causing `git
     # merge-base` to fail.  Passing `--unshallow` to `git fetch` ensures that
@@ -78,6 +80,10 @@ ghc-linters:
   stage: lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
+    # See Note [Unshallow clone for linting]
+    - git fetch --unshallow "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
+    - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
+    - "echo Linting changes between $base..$CI_COMMIT_SHA"
     - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
   dependencies: []
   tags: