From d50bfb49c116d4ffbc12e77e98f8283835d81012 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sat, 27 Jan 2024 18:58:16 -0800 Subject: [PATCH] ci: prevent merge-commits in a PR Have the CI prevent merge-commits being part of a PR --- .github/workflows/lint.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fb7d3f20c..a1980a422 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,3 +41,14 @@ jobs: run: tox -e isort -- --check - name: Run pylint Python code static checker (https://github.com/PyCQA/pylint) run: tox -e pylint + - name: Ensure no merge-commits in the Pull Request (PR) + if: github.event_name == 'pull_request' + run: | + HEAD_SHA="${{ github.event.pull_request.head.sha }}" + echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}" + echo "HEAD_SHA: ${HEAD_SHA}" + MERGE_COMMITS=$(git rev-list --merges origin/${GITHUB_BASE_REF}..${HEAD_SHA}) + if [[ -n "${MERGE_COMMITS}" ]]; then + echo "ERROR: The Pull Request (PR) contains a 'merge commit': ${MERGE_COMMITS}" + exit 1 + fi