From f70eddce5fbe1105943db514d39f2064ab0af0d1 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Tue, 29 Nov 2022 15:43:52 +0100 Subject: [PATCH] github: workflows: compliance: Ensure no merge commits Add a simple one-liner that checks for "0" in the count of merge commits. If a merge commit is present the output will be "1" or higher, failing the job. Signed-off-by: Carles Cufi --- .github/workflows/compliance.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 84953a336857..3a5fc4f9abe2 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -37,6 +37,9 @@ jobs: git config --global user.email "you@example.com" git config --global user.name "Your Name" git remote -v + # Ensure there's no merge commits in the PR + [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ + (echo "::error ::Merge commits not allowed, rebase instead";false) git rebase origin/${BASE_REF} # debug git log --pretty=oneline | head -n 10