conventionalcommit / commitlint

commitlint checks if your commit messages meets the conventional commit format
MIT License
59 stars 4 forks source link

Permit merge commit messages #10

Open danbernier opened 2 years ago

danbernier commented 2 years ago

commitlint fails auto-generated merge-commit messages; these should be allowed.

daniel@cracked project_dir % git merge develop

→ input: "Merge branch 'develop'..."

Errors:
  ❌ parser: type: invalid character ' '

Total 1 errors, 0 warnings, 0 other severities
Not committing merge; use 'git commit' to complete the merge.
gaurav5430 commented 7 months ago

A proper solution would be to have a defaultIgnore + ignore rule as it exists here https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/is-ignored/src/defaults.ts

for now i have added this to my commit-msg file

#!/bin/sh
if ! type commitlint >/dev/null 2>/dev/null; then
    echo ""
    echo "commitlint could not be found"
    echo "try again after installing commitlint or add commitlint to PATH"
    echo ""
    exit 2;
fi

commit_message_file=$(git rev-parse --git-dir)/COMMIT_EDITMSG

# Read the content of the commit message file
commit_message=$(cat "$commit_message_file")

# Check if the commit message starts with "merge"
if [[ "$commit_message" =~ ^merge ]]; then
  # If it starts with "merge", exit without performing validation
  exit 0
fi

commitlint lint --message $1
gumbo2k commented 4 months ago

Yeap. That sounds like we need a whitelist.

I'd suggest a configurable list of regex with a default set that contains all those regex from conventional-changelog's implementation.