Skip to content

Latest commit

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Code Status

Maven CentralLicenseJavadocsCircleCIcodecov

Usage

This plugin lints your git commit message according to the rules you defined.
It basically reads commit message from git repository, matches it with the Regex you provided, before linting each capture group according to your rules.

<plugin>
<groupId>ga.rugal.maven</groupId>
<artifactId>commitlinter-maven-plugin</artifactId>
<version>THE-VERSION-YOU-LIKE</version>
</plugin>

Then run command:

mvn commitlinter:validate

This will report nothing as we haven't configure any linting rules.

Show case

asciicast

Parameters

ParameterTypeDescriptionDefault
captureGroupsCaptureGroup[]List of CaptureGroups[]
captureGroup.caseFormatenumThe case format we want to lintNONE
captureGroup.maxIntegerThe maximum length of this capture groupInteger.MAX
captureGroup.minIntegerThe minimum length of this capture group0
captureGroup.tenseenumThe tense of the initial word of this capture groupNONE
failOnErrorBooleanWhether to fail maven build on linting errorfalse
gitFolderStringThe git repository folder.git
headStringThe pointer of gitHEAD
matchPatternRegexThe regex to match commit message(.*)
skipBooleanWhether to skip lintingfalse
testCommitMessageStringThe commit message to test with""

caseFormat

casesample
UPPERCASETHIS IS UPPER CASE/THIS_IS_UPPER_CASE_TOO
LOWERCASEthis is lower case/this_is_lower_case_too
UPPERCAMELCASEThisIsUpperCamelCase
LOWERCAMELCASEthisIsLowerCamelCase
KEBABCASEthis-is-kebab-case
SNAKECASEthis_is_snake_case
SENTENCECASEThis is sentence case
NONEANY_case-you Like

tense

casesample
PRESENTadd new feature/create a function
PASTadded new feature/created a function
THIRD_PARTYadds new feature/creates a function
NONEany format you like

Simple Example

Please always make sure to wrap the capture group with () so the Regex matcher can capture it.

With Basic Configuration

<plugin>
<groupId>ga.rugal.maven</groupId>
<artifactId>commitlinter-maven-plugin</artifactId>
<version>THE-VERSION-YOU-LIKE</version>
<configuration>
<matchPattern>([\w\s]+-\d+:\s)(.*)</matchPattern>
<failOnError>true</failOnError>
<captureGroups>
<captureGroup>
<max>10</max>
<min>2</min>
<caseFormat>LOWERCASE</caseFormat>
</captureGroup>
<captureGroup>
<max>20</max>
<tense>PRESENT</tense>
<caseFormat>LOWERCASE</caseFormat>
</captureGroup>
</captureGroups>
</configuration>
</plugin>

This configuration will match the git commit message with Regex, then lint them with the rules defined above.

Bind With Lifecycle

This will bind validate goal in validate phase of Maven lifecycle.

<plugin>
<groupId>ga.rugal.maven</groupId>
<artifactId>commitlinter-maven-plugin</artifactId>
<version>THE-VERSION-YOU-LIKE</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<matchPattern>([\w\s]+-\d+:\s)(.*)</matchPattern>
<failOnError>true</failOnError>
<captureGroups>
<captureGroup>
<caseFormat>LOWERCASE</caseFormat>
</captureGroup>
<captureGroup>
<caseFormat>LOWERCASE</caseFormat>
</captureGroup>
</captureGroups>
</configuration>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>

Credit

  • The creation of this plugin is inspired by commitlint

About

Maven plugin for linting git commit message

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages