diff --git a/.github/workflows/commit-message.yml b/.github/workflows/commit-message.yml index cb766b9..d4205a0 100644 --- a/.github/workflows/commit-message.yml +++ b/.github/workflows/commit-message.yml @@ -23,26 +23,29 @@ jobs: git fetch origin $BASE_REF - REGEX="^(feat|fix|docs|chore|refactor|test|hotfix)\([a-z0-9_-]+\): Fixes #[0-9]+ - .+" + # Commits avec numéro d'issue (feat, fix, hotfix, refactor, test) + REGEX_ISSUE="^(feat|fix|hotfix|refactor|test)\([a-z0-9_-]+\): Fixes #[0-9]+ - .+" + # Commits sans numéro d'issue autorisés (chore, docs, ci, fix(ci)) + REGEX_NO_ISSUE="^(chore|docs|ci|fix)\(ci\): .+|^(chore|docs)\([a-z0-9_-]+\): .+" COMMITS=$(git log origin/$BASE_REF..HEAD --pretty=format:"%H") INVALID=false for COMMIT in $COMMITS; do - MESSAGE=$(git log -1 --pretty=format:"%s" $COMMIT) + MESSAGE=$(git log -1 --pretty=format:"%s" $COMMIT | sed 's/^[[:space:]]*//') - # Ignorer les commits de merge - if [[ "$MESSAGE" =~ ^Merge\ ]]; then + # Ignorer tous les commits de merge + if [[ "$MESSAGE" =~ ^Merge ]]; then echo "⏭️ Commit de merge ignoré: $MESSAGE" continue fi - if ! [[ "$MESSAGE" =~ $REGEX ]]; then + if [[ "$MESSAGE" =~ $REGEX_ISSUE ]] || [[ "$MESSAGE" =~ $REGEX_NO_ISSUE ]]; then + echo "✅ Commit valide: $MESSAGE" + else echo "❌ Commit invalide: $MESSAGE" INVALID=true - else - echo "✅ Commit valide: $MESSAGE" fi done