Skip to content

Commit 5c14a71

Browse files
authored
Merge pull request #3667 from Uninett/feat/add-a-github-action-that-blocks-fixup-merge
Add a github action that checks if PRs have any fixup! or amend! commits
2 parents ce9853f + eec327f commit 5c14a71

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Ensure no fixup! or amend! commits are present
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
check-forbidden-commits:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v6
13+
14+
- name: Fetch PR base and head
15+
run: |
16+
git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
17+
git fetch origin ${{ github.event.pull_request.head.ref }}:${{ github.event.pull_request.head.ref }}
18+
19+
- name: Check for fixup! or amend! commits
20+
run: |
21+
COMMITS=$(git log origin/${{ github.event.pull_request.base.ref }}..origin/${{ github.event.pull_request.head.ref }} --pretty=format:"%s")
22+
if echo "$COMMITS" | grep -E '^(fixup!|amend!)'; then
23+
echo "Error: PR contains fixup! or amend! commits. Please squash or rebase before merging."
24+
exit 1
25+
fi

0 commit comments

Comments
 (0)