Skip to content

Commit 6b23487

Browse files
authored
Merge pull request #8 from FabLrc/fix/allow-merge-commits
fix: allow merge commits in conventional commits validation
2 parents 2063012 + b7efd4e commit 6b23487

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

.githooks/commit-msg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
# Types allowed: feat, fix, docs, style, refactor, test, chore, ci, build, perf, revert
1010

1111
subject=$(head -1 "$1")
12+
13+
# Allow system merge commits (GitHub, Git merges)
14+
if echo "$subject" | grep -qE "^(Merge|Squashed|Revert)"; then
15+
exit 0
16+
fi
17+
1218
pattern='^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\(.+\))?!?: .+'
1319

1420
if ! echo "$subject" | grep -qE "$pattern"; then

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
2828
while IFS= read -r msg; do
2929
subject=$(echo "$msg" | head -1)
30+
# Allow system merge commits
31+
if echo "$subject" | grep -qE "^(Merge|Squashed|Revert)"; then
32+
echo "✅ \"$subject\" (merge)"
33+
continue
34+
fi
3035
if ! echo "$subject" | grep -qE "$pattern"; then
3136
echo "❌ \"$subject\""
3237
failed=1
@@ -40,6 +45,7 @@ jobs:
4045
echo "Un ou plusieurs commits ne respectent pas Conventional Commits."
4146
echo "Format attendu : type(scope)?: sujet"
4247
echo "Types autorisés : feat | fix | docs | style | refactor | test | chore | ci | build | perf | revert"
48+
echo "(Les commits de merge Merge/Squashed/Revert sont toujours acceptés)"
4349
exit 1
4450
fi
4551

0 commit comments

Comments
 (0)