Commit 7ffbec63 authored by Ruben ten Hove's avatar Ruben ten Hove
Browse files

disable squash check

parent 418144b5
Loading
Loading
Loading
Loading
+25 −13
Original line number Diff line number Diff line
@@ -5,22 +5,34 @@ check:merge-request:
  variables:
    GIT_STRATEGY: none
  script:
    - apk add --no-cache curl jq
    
    - npm install -g git-conventional-commits

    - git-conventional-commits init

    - |
      curl -sSLf --header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/merge_requests?iids[]=${CI_MERGE_REQUEST_IID}" > /tmp/mr.json
    - echo "${CI_MERGE_REQUEST_TITLE}" > /tmp/mr_title
    - |
      if [ "$(jq -r '.[].squash' test.json)" = "true" ]; then
        echo "[*] Squashing is enabled. Will check the MR title."
        echo "${CI_MERGE_REQUEST_TITLE}" > /tmp/mr_title
        if ! git-conventional-commits commit-msg-hook /tmp/mr_title; then
          exit 1  # The previous command will output a descriptive error
      if git-conventional-commits commit-msg-hook /tmp/mr_title; then
        echo "[+] Merge request title uses conventional commit format. 👍"
      else
          echo "[+] Merge request title looks good."
        fi
      else
        echo "[!] You're not squashing this MR. Ensure all commit messages have a proper format!"  # TODO automatically check this
        exit 1  # The previous command will output a descriptive error
      fi

    # The following is commented out because we currently cannot check if
    # squash is enabled for the current Merge Request
    # - apk add --no-cache curl jq
    # - |
    #   curl -sSLf --header "PRIVATE-TOKEN: ${GL_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/merge_requests?iids[]=${CI_MERGE_REQUEST_IID}" > /tmp/mr.json
    # - |
    #   if [ "$(jq -r '.[].squash' test.json)" = "true" ]; then
    #     echo "[*] Squashing is enabled. Will check the MR title."
        
    #     if ! git-conventional-commits commit-msg-hook /tmp/mr_title; then
    #       exit 1  # The previous command will output a descriptive error
    #     else
    #       echo "[+] Merge request title looks good."
    #     fi
    #   else
    #     echo "[!] You're not squashing this MR. Ensure all commit messages have a proper format!"  # TODO automatically check this
    #   fi
  rules:
    - if: $CI_MERGE_REQUEST_IID