Skip to content

fix: commitlint --last fails #3981

@mfcollins3

Description

@mfcollins3

Steps to Reproduce

I created a valid commit message and used the npx commitlint --last --verbose command to validate the commit message as shown here. I received the following errors:

  • subject may not be empty [subject-empty]
  • type may not be empty [type-empty]

The commit message was:

ci: validate commit messages

I added development dependencies on commitlint and husky. commitlint is
being used to validate commit messages conform to the Conventional
Commits format and follow the configured rules for the project. husky is
being used to run commitlint on every commit using the commit_msg Git
hook.

I created the setup.sh script to automate the steps to install the
project dependencies after cloning the repository.

I updated README.md with instructions on cloning the repository and
running the setup.sh script. I created the software requirements
document to list the software that developers need to install in their
development environments in order to contribute to the product.

I created CONTRIBUTING.md with instructions on how to contribute to the
product. I added instructions on commit signing,
writing commit messages, and the workflows for bug fixes or implementing
new features.

I created the commitlint GitHub Actions workflow to run commitlint to
validate commit messages for the main branch or pull requests for the
main branch.

My configuration is:

export default {
    extends: ['@commitlint/config-conventional'],
    rules: {
        'body-max-line-length': [1, 'always', 72],
        'body-case': [1, 'always', 'sentence-case'],
        'footer-max-line-length': [1, 'always', 72],
        'header-max-length': [2, 'always', 52],
        'scope-enum': [2, 'always', [
            'android',
            'api',
            'flutter',
            'ios'
        ]],
        'type-enum': [2, 'always', [
            'build',
            'change',
            'chore',
            'ci',
            'deprecate',
            'docs',
            'feat',
            'fix',
            'perf',
            'refactor',
            'remove',
            'revert',
            'security',
            'style',
            'test'
        ]]
    }
};

Running npx commitlint --from HEAD~1 --to HEAD --verbose succeeds.



### Current Behavior

```sh
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings

Expected Behavior

Commitlint should succeed and validate that the commit message is valid.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

No response

Context

No response

commitlint --version

@commitlint/[email protected]

git --version

2.44.0

node --version

20.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions