Kambaa / gmc-maven-plugin

A maven plugin that checks given commit messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Git Message Check Maven Plugin

master Sonatype Nexus (Snapshots) CircleCI

Security Rating Reliability RatingVulnerabilities Bugs Coverage

Duplicated Lines (%) Technical Debt Code Smells Lines of Code

A maven plugin that checks given commit messages

In our company, for our maven projects, we use js solutions for commit message convention checking, so i wanted to write a maven plugin to do it. My aim is that this plugin should do pretty much same job as the current status, without the extra unnecessary checks or configurations.

current maven plugin example(that i'm using for dev & testing):

<plugin>
    <groupId>io.github.kambaa</groupId>
    <artifactId>gmc-maven-plugin</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <configuration>
        <!-- (OPTIONAL): fail maven build on error. Default: true -->
        <failOnError>true</failOnError>
        <!-- (OPTIONAL): skips this plugin's execution. Default: false -->
        <skip>false</skip>
    </configuration>
</plugin>

use piping: (TODO: add multiple git log)

 cat .git/COMMIT_EDITMSG | mvn io.github.kambaa:gmc-maven-plugin:checkPiped

My thoughts on current solution:

Apperantly the js solution:

  • calls the git command with arguments itself through a seperate process(code),
  • gets the resulting text from it,
  • splits and processes(not sure) the commits,
  • and does the validations which is abstracted heavily but it's configurative, it can be read through the docs. It covers the variety of checks (which in my opinion and for my needs, it's too many and it's not that needed really 😊 ).

I don't need that much complication, i can write my own bash script to get the git log combined, and give it to this plugin to check'em. Simplicity is enough and great for me. A simple check for extending should be enough for other peoples needs. IDK right now, I will think of a solution later if Allah is willing.

# get commits from latest tag to current with default split text
git log --format="%B%n------------------------ >8 ------------------------" 
$(git describe --tags --abbrev=0)..HEAD

A POC With This Plugin

<plugins>

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
            <execution>
                <id>execute-git-log</id>
                <phase>initialize</phase>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <executable>git</executable>
                    <arguments>
                        <argument>log</argument>
                        <argument>--format=%B%n------------------------ >8 ------------------------</argument>
                        <!--                                <argument>$(git describe &#45;&#45;tags &#45;&#45;abbrev=0)..HEAD</argument>-->
                    </arguments>
                    <outputFile>${project.build.directory}/command-output.txt</outputFile>
                </configuration>
            </execution>
        </executions>
    </plugin>

    <plugin>
        <groupId>io.github.kambaa</groupId>
        <artifactId>gmc-maven-plugin</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <executions>
            <execution>
                <phase>initialize</phase>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                    <multipleGitLogMessages>${project.build.directory}/command-output.txt</multipleGitLogMessages>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

after adding these build configs to a projects pom.xml, i want maven to run the git log command, get the combine commit messages to a file, and gmc plugin to check commits on this file via single command:

mvn initialize io.github.kambaa:gmc-maven-plugin:check -X

Only issue for me to see that there's a newline added between them in command-output.txt. Will check this later.

Some links that i inspired from:

About

A maven plugin that checks given commit messages

License:MIT License


Languages

Language:Java 100.0%