Skip to content

Commit d50bfb4

Browse files
ci: prevent merge-commits in a PR
Have the CI prevent merge-commits being part of a PR
1 parent 7ec3189 commit d50bfb4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.github/workflows/lint.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,14 @@ jobs:
4141
run: tox -e isort -- --check
4242
- name: Run pylint Python code static checker (https://github.com/PyCQA/pylint)
4343
run: tox -e pylint
44+
- name: Ensure no merge-commits in the Pull Request (PR)
45+
if: github.event_name == 'pull_request'
46+
run: |
47+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
48+
echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
49+
echo "HEAD_SHA: ${HEAD_SHA}"
50+
MERGE_COMMITS=$(git rev-list --merges origin/${GITHUB_BASE_REF}..${HEAD_SHA})
51+
if [[ -n "${MERGE_COMMITS}" ]]; then
52+
echo "ERROR: The Pull Request (PR) contains a 'merge commit': ${MERGE_COMMITS}"
53+
exit 1
54+
fi

0 commit comments

Comments
 (0)