diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-06-07 10:55:30 -0400 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2019-06-08 13:34:18 -0400 |
commit | fe9653160be3b025698be9a2a2141b2b87b8ef55 (patch) | |
tree | 793a109b7ed88698227533db1077bf0542ace37e /.gitlab-ci.yml | |
parent | 310d0c4cbc2c847d24408bab92cdae0ed5cc4799 (diff) | |
download | haskell-fe9653160be3b025698be9a2a2141b2b87b8ef55.tar.gz |
gitlab-ci: Use --unshallow when fetching for linters
GitLab creates a shallow clone. However, this means that we may not have
the base commit of an MR when linting, causing `git merge-base` to fail.
Fix this by passing `--unshallow` to `git fetch`, ensuring that we have
the entire history.
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r-- | .gitlab-ci.yml | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35c199f248..fdb4174ddb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,9 +52,13 @@ ghc-linters: stage: lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + # 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 + # we have the entire history. + - git fetch --unshallow "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - "echo Merge base $base" + - "echo Linting changes between $base..$CI_COMMIT_SHA" # - 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 |