conventional-changelog-archived-repos / validate-commit-msg

DEPRECATED. Use https://github.com/marionebl/commitlint instead. githook to validate commit messages are up to standard
http://conventionalcommits.org/
MIT License
557 stars 100 forks source link

How to make multi-line commits #85

Closed danielo515 closed 7 years ago

danielo515 commented 7 years ago

Hello,

I want to use your tool to enforce a commit style on my repository, but I need to be able to make multi line commits. I have a monorepo and this is a very important feature. My commits looks like this:

    fix(DB): fixed the bug 

    affects: module-name

    - Fixed SSL properties are now actual getters
    - Added the missing modules (fs)
    - Test coverage raised again to 100%

I tried updating the subject patten to be "subjectPattern": "[.\n]+", but that didn't worked neither.

Any guidance will be welcome.

Regards

danielo515 commented 7 years ago

Any help with this? I can't find any answer digging around Thanks

kentcdodds commented 7 years ago

Sorry @danielo515, I'm unsure I understand what about the current set up is preventing you from formatting your commits in that way... Do you mean you want to enforce that they're formatted in that way? If so, that's out of the scope for this project. We have a very specific format and don't plan on changing it. Help us understand how to help you.

danielo515 commented 7 years ago

@kentcdodds I thought this module was to enforce angular style, which admits line breaks. So, does validate-commit-msg only allow one line comments? If so, you may want to explicitly say this.

kentcdodds commented 7 years ago

I'm 99% sure that the commit message you have above will pass validate-commit-msg...

DiegoGasco commented 7 years ago

Hello @kentcdodds

There are some messages that pass, and some other that does not, and I'm unable to understand why. Here is an example of another message that fails

feat(consumming): first version of the results fetcher module

affects: case-alerts-results-fetcher

The module is the engine of the service
Added subscription functionality
Added basic unitari tests

May be any other thing ? the verb conjugation? the nouns used?

spirosikmd commented 7 years ago

Hi @DiegoGasco! I tried your message with latest version v2.12.2 and it passes.

var validate = require('validate-commit-msg');

const result = validate(`feat(consuming): first version of the results fetcher module

affects: case-alerts-results-fetcher

The module is the engine of the service
Added subscription functionality
Added basic unitari tests`);

console.log(result); // true

Can you please provide the output of the validation, which should contain something like INVALID COMMIT MSG: "<type>" is not allowed type I guess?

danielo515 commented 7 years ago

I think I have found the problem. The validation is being performed against the previous commit, not the current one. So as long as the previous commit has a valid format, any commit will be accepted. Then, in the next commit, probably a commit with a correct format, the previously bad formatted commit will trigger an exception, leading you to confusion. Is this the expected behavior or maybe a bug? A bug on husky ?

danielo515 commented 7 years ago

Anyone has any answer about why the validation is being performed against the previous commit instead of the current one?

Garbee commented 7 years ago

The validation is being performed against the previous commit, not the current one.

This would need its own bug report with steps to reproduce. Or even a PR with a test case if you can manage writing one. There is no reason I can see within the code that this case should occur.

On the note of multline messages... They shouldn't matter. We split out the first line (since that is the main commit message) and only validate that data.

danielo515 commented 7 years ago

Yes, the multi line issue is resolved. The actual problem was the validation of the previous commit. I'll open a new issue for that