GithubHelp home page GithubHelp logo

godfather1103 / commitlinter-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rugal/commitlinter-maven-plugin

0.0 2.0 0.0 31 KB

Maven plugin for linting git commit message

Java 100.00%

commitlinter-maven-plugin's Introduction

Code Status

Maven Central License Javadocs Build Status codecov Codacy Badge

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

Parameter Type Description Default
captureGroups CaptureGroup[] List of CaptureGroups []
captureGroup.caseFormat enum The case format we want to lint NONE
captureGroup.max Integer The maximum length of this capture group Integer.MAX
captureGroup.min Integer The minimum length of this capture group 0
failOnError Boolean Whether to fail maven build on linting error false
gitFolder String The git repository folder .git
head String The pointer of git HEAD
matchPattern Regex The regex to match commit message (.*)
skip Boolean Whether to skip linting false
testCommitMessage String The commit message to test with ""

caseFormat

case sample
UPPERCASE THIS IS UPPER CASE/THIS_IS_UPPER_CASE_TOO
LOWERCASE this is lower case/this_is_lower_case_too
UPPERCAMELCASE ThisIsUpperCamelCase
LOWERCAMELCASE thisIsLowerCamelCase
KEBABCASE this-is-kebab-case
SNAKECASE this_is_snake_case
SENTENCECASE This is sentence case
NONE ANY_case-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>
        <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

commitlinter-maven-plugin's People

Contributors

rugal avatar

Watchers

Jack Chu avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.