phpro / grumphp

A PHP code-quality tool
MIT License
4.12k stars 430 forks source link

Support Conventional Commits Specification as a task #924

Closed hussainweb closed 2 years ago

hussainweb commented 2 years ago
Q A
Version 1.3.2 (not relevant)
Bug? no
New feature? yes
Question? yes
Documentation? maybe
Related tickets none I could find

I am thinking about using conventional commits as a standard for our projects and was looking at how to enforce that with GrumPHP. Now, this is not hard to implement via the existing git_commit_message task but I am thinking it could be made so much simpler for users by adding a new task for this.

I am happy to write a PR and help test it but I wanted to know what the maintainers thought about this change first. In my mind, I would create a new task class and extend the existing GrumPHP\Task\Git\CommitMessage task. Would you rather prefer another approach or not have this at all?

veewee commented 2 years ago

Hi @hussainweb,

Sounds good! Instead of creating and maintaining something custom inside this package, I'dd rather delegate this task to an external library like https://github.com/ramsey/conventional-commits.

The existing git_commit_message is something that grow organically from a simple regex check to something far more advanced. There are some known issues that are hard to fix because of this. So if we could deprecate (at least some) options from that task in favour for the conventional commit task, I would be happy to include it! :)

Feel free to suggest a PR.

hussainweb commented 2 years ago

That makes sense and I am happy you're open to it. Unfortunately, it seems that using the example you gave would need some work. It has a lot of dependencies, most notably CaptainHook. I don't think that people would use GrumPHP together with CaptainHook. There is no PHAR release either.

I am searching for other packages that do this or just rewrite a similar parser class within GrumPHP. Would you be open to that approach?