Commit 83b277c8 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add pre-commit hook update to pipeline

parent 141daeb3
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -18,13 +18,8 @@
      "
    - |
      git_commit() {
        while test "$1"; do
          case $1 in
            --) shift; MSG=`printf '%s\n\n' "$@" "$MSG_FOOTER"`; break ;;
            *) CHK="$CHK $1"; shift ;;
          esac
        done
        git diff --no-patch --exit-code $CHK ||
        local MSG=`printf '%s\n\n' "$@" "$MSG_FOOTER"`
        git diff --no-patch --exit-code --cached && return
        git commit -m "$MSG"
      }
  after_script:
@@ -35,6 +30,7 @@

stages:
  - submodules
  - pre-commit

workflow:
  rules:
@@ -51,4 +47,22 @@ Update Submodules:
        git checkout origin/${branch:-HEAD} || exit 1
        (cd ${toplevel}; exec git add ${path})
      '
    - git_commit --cached -- "Update submodules" "`git status --short -uno`"
    - git_commit "Update submodules" "`git status --short -uno`"


Update Pre-Commit Hooks:
  stage: pre-commit
  extends: [.git]
  image: docker.kodo.org.uk/ci-images/pre-commit:2.20.0
  script:
    - export GIT_CONFIG=$PWD/.config/git/config
    - TEMPLATE_DIR=`git config init.templateDir`
    - pre-commit init-templatedir
        --hook-type pre-commit
        --hook-type pre-push
        --hook-type prepare-commit-msg
        --hook-type commit-msg
        --hook-type post-checkout
        "${TEMPLATE_DIR/'~'/$PWD}"
    - git add "${TEMPLATE_DIR/'~'/$PWD}"
    - git_commit "Update pre-commit hooks"