├── .github └── workflows │ └── maven.yml ├── .gitignore ├── README.md ├── configuration ├── checkstyle │ ├── checkstyle.xml │ └── suppression.xml └── findbugs │ └── exclude.xml ├── lombok.config ├── pom.xml └── src ├── main ├── java │ └── ga │ │ └── rugal │ │ └── maven │ │ └── plugin │ │ ├── Configuration.java │ │ ├── Constant.java │ │ ├── model │ │ ├── CaptureGroup.java │ │ ├── GitWalker.java │ │ └── RuleChecker.java │ │ ├── mojo │ │ ├── AbstractCommitlinterMojo.java │ │ ├── HookMojo.java │ │ ├── ShowMojo.java │ │ └── ValidateMojo.java │ │ └── rule │ │ ├── CaseRule.java │ │ ├── Kase.java │ │ ├── LengthRule.java │ │ ├── Tense.java │ │ └── TenseRule.java └── resources │ ├── commit-msg │ └── log4j2.xml └── test ├── java └── ga │ └── rugal │ └── maven │ └── plugin │ ├── BaseTest.java │ ├── HookMojoTest.java │ ├── MessageShowMojoFailOnErrorTest.java │ ├── MessageShowMojoSkipTest.java │ ├── MessageShowMojoXmlTest.java │ ├── MessageValidatorMojoFailOnErrorTest.java │ ├── MessageValidatorMojoSkipTest.java │ └── MessageValidatorMojoXmlTest.java └── resources └── unittest ├── failOnErrorFromSystemProperty ├── fail.xml └── success.xml ├── gitfolder ├── fail.xml └── success.xml ├── head ├── fail.xml └── success.xml ├── kebabcase ├── fail.xml └── success.xml ├── lowercamelcase ├── fail.xml └── success.xml ├── lowercase ├── fail.xml └── success.xml ├── max ├── fail.xml └── success.xml ├── min ├── fail.xml └── success.xml ├── nocontent ├── fail.xml └── success.xml ├── none ├── fail.xml └── success.xml ├── past ├── fail.xml └── success.xml ├── present ├── fail.xml └── success.xml ├── sentencecase ├── fail.xml └── success.xml ├── skip ├── fail.xml └── success.xml ├── skipFromSystemProperty ├── fail.xml └── success.xml ├── snakecase ├── fail.xml └── success.xml ├── thirdparty ├── fail.xml └── success.xml ├── unmatch ├── fail.xml └── success.xml ├── uppercamelcase ├── fail.xml └── success.xml └── uppercase ├── fail.xml └── success.xml /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: CI & CD 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | tags: ["v*"] 7 | pull_request: 8 | branches: [master] 9 | 10 | env: 11 | SPRING_PROFILES_ACTIVE: ci 12 | 13 | jobs: 14 | # CI 15 | integration: 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v3 21 | 22 | - name: Setup Java JDK 23 | uses: actions/setup-java@v3 24 | with: 25 | java-version: 11 26 | distribution: adopt 27 | 28 | - name: Restore Build Cache 29 | uses: actions/cache@v3.2.2 30 | with: 31 | path: ~/.m2/repository 32 | key: v1-commitlinter-${{ hashFiles('pom.xml') }} 33 | 34 | - name: Full Test With Maven 35 | run: mvn --no-transfer-progress clean -Dskip.surefire.tests=false -D=skip.failsafe.tests=false verify 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | .settings 5 | nb-configuration.xml 6 | *.swp 7 | *.log 8 | /design/ 9 | /nbproject/ 10 | /nbactions.xml 11 | .idea 12 | *.iml 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Code Status 2 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/ga.rugal.maven/commitlinter-maven-plugin/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/ga.rugal.maven/commitlinter-maven-plugin) 3 | [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) 4 | [![Javadocs](https://javadoc.io/badge/ga.rugal.maven/commitlinter-maven-plugin.svg)](https://javadoc.io/doc/ga.rugal.maven/commitlinter-maven-plugin) 5 | [![CircleCI](https://circleci.com/gh/Rugal/commitlinter-maven-plugin.svg?style=svg)](https://circleci.com/gh/Rugal/commitlinter-maven-plugin) 6 | [![codecov](https://codecov.io/gh/Rugal/commitlinter-maven-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/Rugal/commitlinter-maven-plugin) 7 | 8 | # Usage 9 | This plugin lints your git commit message according to the rules you defined. 10 | It basically reads commit message from git repository, matches it with the Regex you provided, before linting each capture group according to your rules. 11 | 12 | ```xml 13 | 14 | ga.rugal.maven 15 | commitlinter-maven-plugin 16 | THE-VERSION-YOU-LIKE 17 | 18 | ``` 19 | 20 | Then run command: 21 | ```bash 22 | mvn commitlinter:validate 23 | ``` 24 | This will report nothing as we haven't configure any linting rules. 25 | 26 | ## Show case 27 | [![asciicast](https://asciinema.org/a/MkGawonrwNZsrq6gRjzpNS9Cd.png)](https://asciinema.org/a/MkGawonrwNZsrq6gRjzpNS9Cd) 28 | 29 | # Parameters 30 | 31 | Parameter | Type | Description | Default 32 | ---|---|---|--- 33 | captureGroups| CaptureGroup[] | List of CaptureGroups | [] 34 | captureGroup.caseFormat | enum | The case format we want to lint | NONE 35 | captureGroup.max | Integer | The maximum length of this capture group | Integer.MAX 36 | captureGroup.min | Integer | The minimum length of this capture group | 0 37 | captureGroup.tense | enum | The tense of the initial word of this capture group | NONE 38 | failOnError|Boolean | Whether to fail maven build on linting error | false 39 | gitFolder|String|The git repository folder| .git 40 | head|String | The pointer of git | HEAD 41 | matchPattern |Regex|The regex to match commit message|(.*) 42 | skip|Boolean|Whether to skip linting| false 43 | testCommitMessage|String|The commit message to test with|"" 44 | 45 | ## caseFormat 46 | 47 | case | sample 48 | ---|--- 49 | UPPERCASE | THIS IS UPPER CASE/THIS_IS_UPPER_CASE_TOO 50 | LOWERCASE | this is lower case/this_is_lower_case_too 51 | UPPERCAMELCASE | ThisIsUpperCamelCase 52 | LOWERCAMELCASE | thisIsLowerCamelCase 53 | KEBABCASE | this-is-kebab-case 54 | SNAKECASE | this_is_snake_case 55 | SENTENCECASE | This is sentence case 56 | NONE | ANY_case-you Like 57 | 58 | ## tense 59 | 60 | case | sample 61 | ---|--- 62 | PRESENT | add new feature/create a function 63 | PAST | added new feature/created a function 64 | THIRD_PARTY | adds new feature/creates a function 65 | NONE | any format you like 66 | 67 | # Simple Example 68 | Please always make sure to wrap the capture group with `()` so the Regex matcher can capture it. 69 | 70 | ## With Basic Configuration 71 | 72 | ```xml 73 | 74 | ga.rugal.maven 75 | commitlinter-maven-plugin 76 | THE-VERSION-YOU-LIKE 77 | 78 | ([\w\s]+-\d+:\s)(.*) 79 | true 80 | 81 | 82 | 10 83 | 2 84 | LOWERCASE 85 | 86 | 87 | 20 88 | PRESENT 89 | LOWERCASE 90 | 91 | 92 | 93 | 94 | ``` 95 | 96 | This configuration will match the git commit message with Regex, then lint them with the rules defined above. 97 | 98 | ## Bind With Lifecycle 99 | 100 | This will bind `validate` goal in validate phase of Maven lifecycle. 101 | ```xml 102 | 103 | ga.rugal.maven 104 | commitlinter-maven-plugin 105 | THE-VERSION-YOU-LIKE 106 | 107 | 108 | validate 109 | validate 110 | 111 | ([\w\s]+-\d+:\s)(.*) 112 | true 113 | 114 | 115 | LOWERCASE 116 | 117 | 118 | LOWERCASE 119 | 120 | 121 | 122 | 123 | validate 124 | 125 | 126 | 127 | 128 | ``` 129 | 130 | # Credit 131 | * The creation of this plugin is inspired by [commitlint](https://github.com/marionebl/commitlint) 132 | -------------------------------------------------------------------------------- /configuration/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 61 | 62 | 63 | 64 | 65 | 66 | 69 | 70 | 71 | 72 | 73 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 84 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 142 | 143 | 144 | 145 | 147 | 148 | 149 | 150 | 151 | 153 | 154 | 155 | 156 | 158 | 159 | 160 | 161 | 163 | 164 | 165 | 166 | 168 | 169 | 170 | 171 | 173 | 175 | 177 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 212 | 213 | 214 | 215 | 216 | 217 | 220 | 221 | 222 | 223 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 236 | 237 | 238 | 239 | 240 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /configuration/checkstyle/suppression.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /configuration/findbugs/exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lombok.config: -------------------------------------------------------------------------------- 1 | config.stopBubbling = true 2 | lombok.log.fieldName = LOG -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | ga.rugal 6 | parent 7 | 1.14.0 8 | 9 | 10 | ga.rugal.maven 11 | commitlinter-maven-plugin 12 | 1.6.0-SNAPSHOT 13 | maven-plugin 14 | Git Commit Message Linter Maven Plugin 15 | The Maven plugin to lint and validate git commit message 16 | https://github.com/Rugal/commitlinter-maven-plugin 17 | 18 | 19 | 20 | true 21 | true 22 | 23 | 4.4.0 24 | 25 | 26 | 27 | 28 | github issue 29 | https://github.com/Rugal/commitlinter-maven-plugin/issues 30 | 31 | 32 | 33 | https://github.com/Rugal/commitlinter-maven-plugin 34 | scm:git:git://github.com/Rugal/commitlinter-maven-plugin 35 | scm:git:git://github.com/Rugal/commitlinter-maven-plugin 36 | HEAD 37 | 38 | 39 | 40 | 41 | 42 | javax.inject 43 | javax.inject 44 | 45 | 46 | org.apache.maven 47 | maven-artifact 48 | 49 | 50 | org.apache.maven 51 | maven-compat 52 | 53 | 54 | org.apache.maven 55 | maven-core 56 | 57 | 58 | org.apache.maven 59 | maven-plugin-api 60 | 61 | 62 | org.apache.maven.plugin-tools 63 | maven-plugin-annotations 64 | 65 | 66 | org.apache.maven.plugin-testing 67 | maven-plugin-testing-harness 68 | test 69 | 70 | 71 | org.eclipse.jgit 72 | org.eclipse.jgit 73 | 74 | 75 | org.projectlombok 76 | lombok 77 | 78 | 79 | edu.stanford.nlp 80 | stanford-corenlp 81 | ${stanford.version} 82 | 83 | 84 | 85 | edu.stanford.nlp 86 | stanford-corenlp 87 | ${stanford.version} 88 | models 89 | 90 | 91 | 92 | com.github.spotbugs 93 | spotbugs-annotations 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.apache.maven.plugins 101 | maven-plugin-plugin 102 | 103 | 104 | 105 | org.apache.maven.plugins 106 | maven-site-plugin 107 | 3.10.0 108 | 109 | 110 | 111 | org.apache.maven.plugins 112 | maven-project-info-reports-plugin 113 | 3.2.1 114 | 115 | 116 | 117 | org.apache.maven.plugins 118 | maven-checkstyle-plugin 119 | 120 | 121 | 122 | com.github.spotbugs 123 | spotbugs-maven-plugin 124 | 125 | 126 | 127 | org.apache.maven.plugins 128 | maven-pmd-plugin 129 | 130 | 131 | 132 | org.apache.maven.plugins 133 | maven-surefire-plugin 134 | 135 | 136 | 137 | org.apache.maven.plugins 138 | maven-failsafe-plugin 139 | 140 | 141 | 142 | org.jacoco 143 | jacoco-maven-plugin 144 | 145 | 146 | 147 | org.apache.maven.plugins 148 | maven-source-plugin 149 | 150 | 151 | 152 | org.apache.maven.plugins 153 | maven-javadoc-plugin 154 | 155 | 156 | 157 | org.apache.maven.plugins 158 | maven-compiler-plugin 159 | 160 | 161 | 162 | org.sonatype.plugins 163 | nexus-staging-maven-plugin 164 | 165 | 166 | org.apache.maven.plugins 167 | maven-release-plugin 168 | 169 | 170 | 171 | 172 | org.eclipse.sisu 173 | sisu-maven-plugin 174 | 175 | 176 | 177 | generate-index 178 | 179 | main-index 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/Configuration.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import ga.rugal.maven.plugin.model.CaptureGroup; 4 | 5 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 6 | import lombok.Builder; 7 | import lombok.Value; 8 | 9 | /** 10 | * Class for storing linting configuration. 11 | * 12 | * @author rugal 13 | */ 14 | @Builder 15 | @SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"}) 16 | @Value 17 | public class Configuration { 18 | 19 | /** 20 | * If commitlinter will skip.
21 | * Also configurable through Maven or System property: ${commitlinter.skip}. 22 | */ 23 | private boolean skip; 24 | 25 | /** 26 | * Local git folder.
27 | * Also configurable through Maven or System property: ${commitlinter.gitFolder}. 28 | */ 29 | private String gitFolder; 30 | 31 | /** 32 | * The head ref to check for.
33 | * Also configurable through Maven or System property: ${commitlinter.head}. 34 | */ 35 | private String head; 36 | 37 | /** 38 | * Fail the build if commitlinter check not pass.
39 | * Also configurable through Maven or System property: ${commitlinter.failOnError}. 40 | */ 41 | private boolean failOnError; 42 | 43 | /** 44 | * The test commit message only for testing purpose.
45 | * Also configurable through Maven or System property: ${commitlinter.testCommitMessage}. 46 | */ 47 | private String testCommitMessage; 48 | 49 | /** 50 | * The regex pattern to match.
51 | * Also configurable through Maven or System property: ${commitlinter.matchPattern}. 52 | */ 53 | private String matchPattern; 54 | 55 | /** 56 | * The capture group configuration for regex to split. Unable to configure through system 57 | * property. 58 | */ 59 | private CaptureGroup[] captureGroups; 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/Constant.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | /** 4 | * Class that contains constant value.
5 | * Possibily change to kotlin object class. 6 | * 7 | * @author Rugal Bernstein 8 | */ 9 | public interface Constant { 10 | 11 | // default property value 12 | String GIT_FOLDER_DEFAULT = ".git"; 13 | 14 | String HEAD_DEFAULT = "HEAD"; 15 | 16 | boolean FAIL_ON_ERROR_DEFAULT = false; 17 | 18 | boolean SKIP_DEFAULT = false; 19 | 20 | String MATCH_PATTERN_DEFAULT = "(.*)"; 21 | 22 | // log format 23 | String LOG_FORMAT = "%n%-20s:[%b]" 24 | + "%n%-20s:[%b]" 25 | + "%n%-20s:[%s]" 26 | + "%n%-20s:[%s]" 27 | + "%n%-20s:[%s]" 28 | + "%n%-20s:[%s]" 29 | + "%n%-20s:[%s]%n"; 30 | 31 | String CAPTURE_LOG_FORMAT = "%n%-15s:[%s]" 32 | + "%n%-15s:[%s]" 33 | + "%n%-15s:[%d]" 34 | + "%n%-15s:[%d]%n"; 35 | 36 | // system property name 37 | String FAIL_ON_ERROR = "commitlinter.failOnError"; 38 | 39 | String GIT_FOLDER = "commitlinter.gitFolder"; 40 | 41 | String HEAD = "commitlinter.head"; 42 | 43 | String MATCH_PATTERN = "commitlinter.matchPattern"; 44 | 45 | String SKIP = "commitlinter.skip"; 46 | 47 | String TEST_COMMIT_MESSAGE = "commitlinter.testCommitMessage"; 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/model/CaptureGroup.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.model; 2 | 3 | import ga.rugal.maven.plugin.rule.Kase; 4 | import ga.rugal.maven.plugin.rule.Tense; 5 | 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | 9 | /** 10 | * Define rules to be enforced on a capture group. 11 | * 12 | * @author Rugal Bernstein 13 | */ 14 | @Getter 15 | @NoArgsConstructor 16 | public class CaptureGroup { 17 | 18 | private Kase caseFormat = Kase.NONE; 19 | 20 | private int max = Integer.MAX_VALUE; 21 | 22 | private int min = 0; 23 | 24 | private Tense tense = Tense.NONE; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/model/GitWalker.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.model; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.regex.Matcher; 6 | import java.util.regex.Pattern; 7 | 8 | import lombok.AllArgsConstructor; 9 | import org.apache.maven.plugin.MojoFailureException; 10 | import org.apache.maven.plugin.logging.Log; 11 | import org.eclipse.jgit.errors.RevisionSyntaxException; 12 | import org.eclipse.jgit.lib.Repository; 13 | import org.eclipse.jgit.revwalk.RevCommit; 14 | import org.eclipse.jgit.revwalk.RevWalk; 15 | import org.eclipse.jgit.storage.file.FileRepositoryBuilder; 16 | 17 | /** 18 | * A walker object to go through Git repository. 19 | * 20 | * @author Rugal Bernstein 21 | */ 22 | @AllArgsConstructor 23 | public class GitWalker { 24 | 25 | private final Log log; 26 | 27 | private final String gitFolder; 28 | 29 | private final String head; 30 | 31 | private final String matchPattern; 32 | 33 | private final String testCommitMessage; 34 | 35 | /** 36 | * Get latest commit message from git repository. 37 | * 38 | * @return the most recent commit message 39 | * 40 | * @throws IOException when unable to read from file system 41 | * @throws RevisionSyntaxException when revision error 42 | */ 43 | public String getRecentCommitMessage() throws IOException, RevisionSyntaxException { 44 | try { 45 | // Open an existing repository 46 | final FileRepositoryBuilder builder = new FileRepositoryBuilder(); 47 | builder.setGitDir(new File(this.gitFolder)); 48 | final Repository repository = builder.build(); 49 | final RevWalk walk = new RevWalk(repository); 50 | final RevCommit commit = walk.parseCommit(repository.resolve(this.head)); 51 | final String commitMessage = commit.getShortMessage(); 52 | walk.dispose(); 53 | this.log.debug(String.format("Find commit message from git [%s]", commitMessage)); 54 | return commitMessage; 55 | } catch (IOException | NullPointerException | RevisionSyntaxException e) { 56 | this.log.error("Unable to open .git directory"); 57 | throw e; 58 | } 59 | } 60 | 61 | /** 62 | * Extract content from special characters. 63 | * 64 | * @param capturedString entire commit message 65 | * 66 | * @return the pattern matched string 67 | * 68 | * @throws MojoFailureException When Mojo failed 69 | */ 70 | public String extractContent(final String capturedString) throws MojoFailureException { 71 | final Pattern pattern = Pattern.compile("[\\w\\d\\s-_]+"); 72 | final Matcher matcher = pattern.matcher(capturedString); 73 | 74 | if (!matcher.find()) { 75 | throw new MojoFailureException(String.format("No content found [%s]", capturedString)); 76 | } 77 | return matcher.group().trim(); 78 | } 79 | 80 | /** 81 | * Get most recent commit message and match it with our pattern. 82 | * 83 | * @return The pattern matcher. 84 | * 85 | * @throws RevisionSyntaxException when revision error 86 | * @throws IOException Unable to read git repository 87 | */ 88 | public Matcher patternMatcher() throws RevisionSyntaxException, IOException { 89 | String commitMessage = this.getRecentCommitMessage(); 90 | if (null != this.testCommitMessage) { 91 | commitMessage = this.testCommitMessage; 92 | this.log.debug(String.format("Use test commit message [%s]", this.testCommitMessage)); 93 | } 94 | final Pattern pattern = Pattern.compile(this.matchPattern); 95 | return pattern.matcher(commitMessage); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/model/RuleChecker.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.model; 2 | 3 | import ga.rugal.maven.plugin.rule.CaseRule; 4 | import ga.rugal.maven.plugin.rule.LengthRule; 5 | import ga.rugal.maven.plugin.rule.TenseRule; 6 | 7 | import lombok.AllArgsConstructor; 8 | import org.apache.maven.plugin.logging.Log; 9 | 10 | /** 11 | * To check rules against a matched string. 12 | * 13 | * @author Rugal Bernstein 14 | */ 15 | @AllArgsConstructor 16 | public class RuleChecker { 17 | 18 | private final CaptureGroup captureGroup; 19 | 20 | private final Log log; 21 | 22 | /** 23 | * Check a matched string with given rules. 24 | * 25 | * @param match The input string 26 | * 27 | * @return How many failed checks in this string 28 | */ 29 | public int check(final String match) { 30 | int failed = 0; 31 | this.log.info(String.format("Linting: [%s]", match)); 32 | if (!CaseRule.validate(match, this.captureGroup.getCaseFormat())) { 33 | this.log.error(String.format(" Case format should be %s", 34 | this.captureGroup.getCaseFormat().name())); 35 | failed++; 36 | } 37 | if (!TenseRule.validate(match, this.captureGroup.getTense())) { 38 | this.log.error(String.format(" Tense of initial word should be %s", 39 | this.captureGroup.getTense().name())); 40 | failed++; 41 | } 42 | if (!LengthRule.fitMax(match, this.captureGroup.getMax())) { 43 | this.log.error(String.format(" Length should be no more than %d", 44 | this.captureGroup.getMax())); 45 | failed++; 46 | } 47 | if (!LengthRule.fitMin(match, this.captureGroup.getMin())) { 48 | this.log.error(String.format(" Length should be no less than %d", 49 | this.captureGroup.getMin())); 50 | failed++; 51 | } 52 | return failed; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/mojo/AbstractCommitlinterMojo.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.mojo; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import ga.rugal.maven.plugin.Configuration; 7 | import ga.rugal.maven.plugin.Constant; 8 | import ga.rugal.maven.plugin.model.CaptureGroup; 9 | 10 | import org.apache.maven.plugin.AbstractMojo; 11 | import org.apache.maven.plugin.MojoExecutionException; 12 | import org.apache.maven.plugin.MojoFailureException; 13 | import org.apache.maven.plugins.annotations.Parameter; 14 | 15 | /** 16 | * Abstract class for basic and common logic. 17 | * 18 | * @author Rugal 19 | */ 20 | public abstract class AbstractCommitlinterMojo extends AbstractMojo { 21 | 22 | @Parameter 23 | private boolean skip = Constant.SKIP_DEFAULT; 24 | 25 | @Parameter 26 | private String gitFolder = Constant.GIT_FOLDER_DEFAULT; 27 | 28 | @Parameter 29 | private String head = Constant.HEAD_DEFAULT; 30 | 31 | @Parameter 32 | private boolean failOnError = Constant.FAIL_ON_ERROR_DEFAULT; 33 | 34 | @Parameter 35 | private String testCommitMessage; 36 | 37 | @Parameter 38 | private String matchPattern = Constant.MATCH_PATTERN_DEFAULT; 39 | 40 | @Parameter 41 | private CaptureGroup[] captureGroups = new CaptureGroup[0]; 42 | 43 | /** 44 | * Read some property from system property. 45 | */ 46 | private void read(final Map map, final String key) { 47 | final String property = System.getProperty(key); 48 | if (null != property) { 49 | map.put(key, property); 50 | } 51 | } 52 | 53 | /** 54 | * Group system property into map. 55 | * 56 | * @return the complete environment variables 57 | */ 58 | private Map readSystemProperty() { 59 | final Map map = new HashMap<>(); 60 | this.read(map, Constant.FAIL_ON_ERROR); 61 | this.read(map, Constant.GIT_FOLDER); 62 | this.read(map, Constant.HEAD); 63 | this.read(map, Constant.MATCH_PATTERN); 64 | this.read(map, Constant.SKIP); 65 | this.read(map, Constant.TEST_COMMIT_MESSAGE); 66 | return map; 67 | } 68 | 69 | private Configuration getConfiguration() { 70 | final Map map = this.readSystemProperty(); 71 | this.failOnError = Boolean.parseBoolean(map.getOrDefault(Constant.FAIL_ON_ERROR, 72 | Boolean.toString(this.failOnError))); 73 | this.gitFolder = map.getOrDefault(Constant.GIT_FOLDER, this.gitFolder); 74 | this.head = map.getOrDefault(Constant.HEAD, this.head); 75 | this.matchPattern = map.getOrDefault(Constant.MATCH_PATTERN, this.matchPattern); 76 | this.skip = Boolean.parseBoolean(map.getOrDefault(Constant.SKIP, 77 | Boolean.toString(this.skip))); 78 | this.testCommitMessage = map.getOrDefault(Constant.TEST_COMMIT_MESSAGE, this.testCommitMessage); 79 | 80 | return Configuration.builder() 81 | .captureGroups(this.captureGroups) 82 | .failOnError(this.failOnError) 83 | .gitFolder(this.gitFolder) 84 | .head(this.head) 85 | .matchPattern(this.matchPattern) 86 | .skip(this.skip) 87 | .testCommitMessage(this.testCommitMessage) 88 | .build(); 89 | } 90 | 91 | /** 92 | * Execute commitlinter mojo. 93 | * 94 | * @param configuration all preset configuration, priority is 1. system property 2. configuration 95 | * 3. default value 96 | * 97 | * @throws MojoExecutionException when execution has any problem 98 | * @throws MojoFailureException when fail the execution 99 | */ 100 | public abstract void execute(Configuration configuration) throws MojoExecutionException, 101 | MojoFailureException; 102 | 103 | @Override 104 | public void execute() throws MojoExecutionException, MojoFailureException { 105 | this.execute(this.getConfiguration()); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/mojo/HookMojo.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.mojo; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.net.URISyntaxException; 6 | import java.nio.file.Paths; 7 | 8 | import ga.rugal.maven.plugin.Configuration; 9 | 10 | import org.apache.commons.io.FileUtils; 11 | import org.apache.maven.plugin.MojoExecutionException; 12 | import org.apache.maven.plugin.MojoFailureException; 13 | import org.apache.maven.plugin.logging.Log; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | 16 | /** 17 | * Install git hook as commit-msg. 18 | * 19 | * @author Rugal 20 | */ 21 | @Mojo(name = "hook") 22 | public class HookMojo extends AbstractCommitlinterMojo { 23 | 24 | @Override 25 | public void execute(final Configuration c) throws MojoExecutionException, MojoFailureException { 26 | final Log log = this.getLog(); 27 | try { 28 | final var r = this.getClass().getClassLoader().getResource("commit-msg"); 29 | final var source = Paths.get(r.toURI()); 30 | final var target = String.format("%s/hooks/commit-msg", c.getGitFolder()); 31 | log.info(String.format("Write hook file to [%s]", target)); 32 | FileUtils.copyFile(source.toFile(), new File(target)); 33 | } catch (final URISyntaxException ex) { 34 | log.error("Invalid source file path", ex); 35 | throw new MojoExecutionException("Invalid source file path"); 36 | } catch (final IOException ex) { 37 | log.error("Unable to write file", ex); 38 | throw new MojoExecutionException("Unable to write file"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/mojo/ShowMojo.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.mojo; 2 | 3 | import java.io.IOException; 4 | 5 | import ga.rugal.maven.plugin.Configuration; 6 | import ga.rugal.maven.plugin.Constant; 7 | import ga.rugal.maven.plugin.model.CaptureGroup; 8 | import ga.rugal.maven.plugin.model.GitWalker; 9 | 10 | import org.apache.maven.plugin.MojoExecutionException; 11 | import org.apache.maven.plugin.MojoFailureException; 12 | import org.apache.maven.plugin.logging.Log; 13 | import org.apache.maven.plugins.annotations.Mojo; 14 | import org.eclipse.jgit.errors.RevisionSyntaxException; 15 | 16 | /** 17 | * Show commit linter configuration and basic git information. 18 | * 19 | * @author Rugal 20 | */ 21 | @Mojo(name = "show") 22 | public class ShowMojo extends AbstractCommitlinterMojo { 23 | 24 | @Override 25 | public void execute(final Configuration c) throws MojoExecutionException, MojoFailureException { 26 | final Log log = this.getLog(); 27 | final GitWalker walker = new GitWalker(this.getLog(), 28 | c.getGitFolder(), 29 | c.getHead(), 30 | c.getMatchPattern(), 31 | c.getTestCommitMessage()); 32 | try { 33 | final String string = String.format(Constant.LOG_FORMAT, 34 | "skip", c.isSkip(), 35 | "failOnError", c.isFailOnError(), 36 | "gitFolder", c.getGitFolder(), 37 | "head", c.getHead(), 38 | "testCommitMessage", c.getTestCommitMessage(), 39 | "matchPattern", c.getMatchPattern(), 40 | "CommitMessage", walker.getRecentCommitMessage()); 41 | log.info("Basic Configuration"); 42 | log.info(string); 43 | log.info("Capture Group Definition:"); 44 | for (CaptureGroup group : c.getCaptureGroups()) { 45 | log.info(String.format(Constant.CAPTURE_LOG_FORMAT, 46 | "CaseFormat", group.getCaseFormat(), 47 | "Tense", group.getTense(), 48 | "MinimunLength", group.getMin(), 49 | "MaximumLength", group.getMax())); 50 | } 51 | } catch (IOException | RevisionSyntaxException | NullPointerException ex) { 52 | throw new MojoFailureException("Unable to lint commit message due to git repository error"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/mojo/ValidateMojo.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.mojo; 2 | 3 | import java.io.IOException; 4 | import java.util.regex.Matcher; 5 | 6 | import ga.rugal.maven.plugin.Configuration; 7 | import ga.rugal.maven.plugin.model.CaptureGroup; 8 | import ga.rugal.maven.plugin.model.GitWalker; 9 | import ga.rugal.maven.plugin.model.RuleChecker; 10 | 11 | import org.apache.maven.plugin.MojoExecutionException; 12 | import org.apache.maven.plugin.MojoFailureException; 13 | import org.apache.maven.plugins.annotations.LifecyclePhase; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.eclipse.jgit.errors.RevisionSyntaxException; 16 | 17 | /** 18 | * Validate Git commit message. 19 | * 20 | * @author Rugal 21 | */ 22 | @Mojo(name = "validate", defaultPhase = LifecyclePhase.VALIDATE) 23 | public class ValidateMojo extends AbstractCommitlinterMojo { 24 | 25 | @Override 26 | public void execute(final Configuration c) throws MojoExecutionException, MojoFailureException { 27 | if (c.isSkip()) { 28 | this.getLog().info("Skip Commitlinter"); 29 | return; 30 | } 31 | try { 32 | final GitWalker walker = new GitWalker(this.getLog(), 33 | c.getGitFolder(), 34 | c.getHead(), 35 | c.getMatchPattern(), 36 | c.getTestCommitMessage()); 37 | final Matcher matcher = walker.patternMatcher(); 38 | if (!matcher.find()) { 39 | throw new MojoFailureException(String.format("No pattern matched by Regex: [%s]", 40 | c.getMatchPattern())); 41 | } 42 | 43 | int result = 0; 44 | final CaptureGroup[] cg = c.getCaptureGroups(); 45 | for (int i = 1; i <= Math.min(cg.length, matcher.groupCount()); i++) { 46 | final String extractedContent = walker.extractContent(matcher.group(i)); 47 | this.getLog().debug(extractedContent); 48 | final RuleChecker checker = new RuleChecker(cg[i - 1], this.getLog()); 49 | result += checker.check(extractedContent); 50 | } 51 | if (0 == result) { 52 | return; 53 | } 54 | if (c.isFailOnError()) { 55 | throw new MojoFailureException("Commit Lint failed, please check rules"); 56 | } 57 | } catch (IOException | RevisionSyntaxException | NullPointerException ex) { 58 | ex.printStackTrace(); 59 | throw new MojoFailureException("Unable to lint commit message due to git repository error"); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/rule/CaseRule.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.rule; 2 | 3 | import java.util.Locale; 4 | 5 | /** 6 | * Check case format of text. 7 | * 8 | * @author Rugal Bernstein 9 | */ 10 | public class CaseRule { 11 | 12 | private CaseRule() { 13 | } 14 | 15 | /** 16 | * Check text with given format. 17 | * 18 | * @param text The input string 19 | * @param pattern The case format to accept 20 | * 21 | * @return If the input string matches the given case format 22 | */ 23 | public static boolean validate(final String text, final Kase pattern) { 24 | final boolean result; 25 | switch (pattern) { 26 | case LOWERCASE: 27 | result = isLowerCase(text); 28 | break; 29 | case UPPERCASE: 30 | result = isUpperCase(text); 31 | break; 32 | case UPPERCAMELCASE: 33 | result = isUpperCamelCase(text); 34 | break; 35 | case LOWERCAMELCASE: 36 | result = isLowerCamelCase(text); 37 | break; 38 | case KEBABCASE: 39 | result = isKebabCase(text); 40 | break; 41 | case SNAKECASE: 42 | result = isSnakeCase(text); 43 | break; 44 | case SENTENCECASE: 45 | result = isSentenceCase(text); 46 | break; 47 | case NONE: 48 | default: 49 | result = true; 50 | } 51 | return result; 52 | } 53 | 54 | /** 55 | * Check text is camel case. 56 | * 57 | * @param text The input string 58 | * 59 | * @return If the input string matches the given case format 60 | */ 61 | private static boolean isCamelCase(final String text) { 62 | return !text.contains("_") 63 | && !text.contains("-") 64 | && !text.contains(" "); 65 | } 66 | 67 | /** 68 | * Check specifically for upper camel case.
69 | * ThisIsUpperCamelCase 70 | * 71 | * @param text The input string 72 | * 73 | * @return If the input string matches the given case format 74 | */ 75 | public static boolean isUpperCamelCase(final String text) { 76 | return isCamelCase(text) && Character.isUpperCase(text.charAt(0)); 77 | } 78 | 79 | /** 80 | * Check specifically for lower camel case.
81 | * thisIsLowerCamelCase 82 | * 83 | * @param text The input string 84 | * 85 | * @return If the input string matches the given case format 86 | */ 87 | public static boolean isLowerCamelCase(final String text) { 88 | return isCamelCase(text) && Character.isLowerCase(text.charAt(0)); 89 | } 90 | 91 | /** 92 | * Check specifically for upper case.
93 | * THIS IS UPPER CASE / THISISALSOUPPERCASE 94 | * 95 | * @param text The input string 96 | * 97 | * @return If the input string matches the given case format 98 | */ 99 | public static boolean isUpperCase(final String text) { 100 | return text.toUpperCase(Locale.ENGLISH).equals(text); 101 | } 102 | 103 | /** 104 | * Check specifically for lower case.
105 | * this is lower case / thisisalsolowercase 106 | * 107 | * @param text The input string 108 | * 109 | * @return If the input string matches the given case format 110 | */ 111 | public static boolean isLowerCase(final String text) { 112 | return text.toLowerCase(Locale.ENGLISH).equals(text); 113 | } 114 | 115 | /** 116 | * Check specifically for kebab case.
117 | * this-is-kebab-case-which-comes-from-lisp 118 | * 119 | * @param text The input string 120 | * 121 | * @return If the input string matches the given case format 122 | */ 123 | public static boolean isKebabCase(final String text) { 124 | return text.toLowerCase(Locale.ENGLISH).replaceAll("_", "-").replaceAll(" ", "-").equals(text); 125 | } 126 | 127 | /** 128 | * Check specifically for sentence case.
129 | * This is sentence case / It's first character of first word is capitalized 130 | * 131 | * @param text The input string 132 | * 133 | * @return If the input string matches the given case format 134 | */ 135 | public static boolean isSentenceCase(final String text) { 136 | return Character.isUpperCase(text.charAt(0)) && isLowerCase(text.substring(1)); 137 | } 138 | 139 | /** 140 | * Check specifically for snake case.
141 | * this_is_snake_case / which_is_used_a_lot_in_database_table_design 142 | * 143 | * @param text The input string 144 | * 145 | * @return If the input string matches the given case format 146 | */ 147 | public static boolean isSnakeCase(final String text) { 148 | return text.toLowerCase(Locale.ENGLISH).replace(" ", "_").replace("-", "_").equals(text); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/rule/Kase.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.rule; 2 | 3 | /** 4 | * The case enum to verify. 5 | * 6 | * @author Rugal Bernstein 7 | */ 8 | public enum Kase { 9 | 10 | UPPERCASE, LOWERCASE, 11 | UPPERCAMELCASE, LOWERCAMELCASE, 12 | KEBABCASE, 13 | SNAKECASE, 14 | SENTENCECASE, 15 | NONE 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/rule/LengthRule.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.rule; 2 | 3 | /** 4 | * Check length related rules. 5 | * 6 | * @author Rugal Bernstein 7 | */ 8 | public class LengthRule { 9 | 10 | private LengthRule() { 11 | } 12 | 13 | /** 14 | * Check text length is no more than max. 15 | * 16 | * @param text The input string 17 | * @param max The maximum length accepted 18 | * @return If the input string follows the rule 19 | */ 20 | public static boolean fitMax(final String text, final int max) { 21 | return text.length() <= max; 22 | } 23 | 24 | /** 25 | * Check text length is no less than min. 26 | * 27 | * @param text The input string 28 | * @param min The minimum length accepted 29 | * @return If the input string follows the rule 30 | */ 31 | public static boolean fitMin(final String text, final int min) { 32 | return text.length() >= min; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/rule/Tense.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.rule; 2 | 3 | /** 4 | * The case enum to verify. 5 | * 6 | * @author Rugal Bernstein 7 | */ 8 | public enum Tense { 9 | PRESENT, 10 | PAST, 11 | THIRD_PARTY, 12 | NONE 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ga/rugal/maven/plugin/rule/TenseRule.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin.rule; 2 | 3 | import java.util.Locale; 4 | import java.util.Set; 5 | 6 | import com.google.common.collect.ImmutableSet; 7 | import edu.stanford.nlp.simple.Sentence; 8 | 9 | /** 10 | * Check tense related rules. 11 | * 12 | * @author Rugal Bernstein 13 | */ 14 | public class TenseRule { 15 | 16 | private static final Set PAST_TENSE = ImmutableSet.of("VBN", "VBD"); 17 | 18 | private static final Set THIRD_PARTY_TENSE = ImmutableSet.of("VBZ"); 19 | 20 | private static final Set PRESENT_TENSE = ImmutableSet.of("VB", "VBP"); 21 | 22 | private TenseRule() { 23 | } 24 | 25 | private static boolean matchTense(final Set pattern, final String word) { 26 | final Sentence sent = new Sentence(word); 27 | final String toUpperCase = sent.posTag(0).toUpperCase(Locale.US); 28 | return pattern.contains(toUpperCase); 29 | } 30 | 31 | /** 32 | * Check word is past tense. 33 | * 34 | * @param word target word or sentence 35 | * 36 | * @return true if word is past tense, otherwise return false 37 | */ 38 | public static boolean isPastTense(final String word) { 39 | return matchTense(PAST_TENSE, word); 40 | } 41 | 42 | /** 43 | * Check word is third party tense. 44 | * 45 | * @param word target word or sentence 46 | * 47 | * @return true if word is third party tense, otherwise return false 48 | */ 49 | public static boolean isPresentTense(final String word) { 50 | return matchTense(PRESENT_TENSE, word); 51 | } 52 | 53 | /** 54 | * Check word is third party tense. 55 | * 56 | * @param word target word or sentence 57 | * 58 | * @return true if word is third party tense, otherwise return false 59 | */ 60 | public static boolean isThirdPartyTense(final String word) { 61 | return matchTense(THIRD_PARTY_TENSE, word); 62 | } 63 | 64 | /** 65 | * Check text with given tense. 66 | * 67 | * @param word The input string 68 | * @param tense The tense to accept 69 | * 70 | * @return If the input string matches the given case format 71 | */ 72 | public static boolean validate(final String word, final Tense tense) { 73 | final boolean result; 74 | switch (tense) { 75 | case PRESENT: 76 | result = isPresentTense(word); 77 | break; 78 | case PAST: 79 | result = isPastTense(word); 80 | break; 81 | case THIRD_PARTY: 82 | result = isThirdPartyTense(word); 83 | break; 84 | case NONE: 85 | default: 86 | result = true; 87 | } 88 | return result; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/resources/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | file=$1 3 | message=`cat $file` 4 | mvn ga.rugal.maven:commitlinter-maven-plugin:validate -DtestCommitMessage=${message} 5 | -------------------------------------------------------------------------------- /src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | target/app.log 5 | 6 | 7 | 8 | 9 | 10 | %date{yyyy-mm-dd HH:mm} - %highlight{[%-5level]}{FATAL=Yellow, ERROR=red, WARN=Magenta, INFO=Bright Green, DEBUG=Bright Cyan, TRACE=Bright White} %class#%line - %message %n 11 | 12 | 13 | 14 | 15 | 16 | 17 | %date{yyyy-mm-dd HH:mm} - %highlight{[%-5level]}{FATAL=Yellow, ERROR=red, WARN=Magenta, INFO=Bright Green, DEBUG=Bright Cyan, TRACE=Bright White} %class#%line - %message %n 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/BaseTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import java.io.File; 4 | 5 | import org.apache.maven.plugin.AbstractMojo; 6 | import org.apache.maven.plugin.testing.MojoRule; 7 | import org.junit.Assert; 8 | import org.junit.Ignore; 9 | import org.junit.Rule; 10 | import org.junit.runners.Parameterized.Parameter; 11 | 12 | /** 13 | * 14 | * @author Rugal Bernstein 15 | */ 16 | @Ignore 17 | public class BaseTest { 18 | 19 | public static final String SUCCESS = "success"; 20 | 21 | public static final String FAIL = "fail"; 22 | 23 | private static final String TEMPLATE = "src/test/resources/unittest/%s/%s.xml"; 24 | 25 | @Parameter 26 | public String caseFormat; 27 | 28 | @Rule 29 | public MojoRule rule = new MojoRule(); 30 | 31 | /** 32 | * Get Mojo object from each pom file. 33 | * 34 | * @param mojoName name of mojo 35 | * @param caseFormat string case format 36 | * @param result expected result 37 | * 38 | * @return created mojo 39 | * 40 | * @throws Exception unable to find target mojo 41 | */ 42 | protected AbstractMojo getMojo(final String mojoName, 43 | final String caseFormat, 44 | final String result) throws Exception { 45 | final File pom = new File(String.format(TEMPLATE, caseFormat, result)); 46 | Assert.assertTrue(pom.exists()); 47 | Assert.assertNotNull(pom); 48 | Assert.assertTrue(pom.exists()); 49 | 50 | final AbstractMojo mojo = (AbstractMojo) this.rule.lookupMojo(mojoName, pom); 51 | Assert.assertNotNull(mojo); 52 | return mojo; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/HookMojoTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import lombok.SneakyThrows; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | /** 8 | * 9 | * @author Rugal Bernstein 10 | */ 11 | public class HookMojoTest extends BaseTest { 12 | 13 | /** 14 | * These tests should success. 15 | * 16 | * @throws Exception 17 | */ 18 | @SneakyThrows 19 | @Test 20 | public void caseSuccess() { 21 | final var mojo = this.getMojo("hook", "head", SUCCESS); 22 | Assert.assertNotNull(mojo); 23 | mojo.execute(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/MessageShowMojoFailOnErrorTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import static ga.rugal.maven.plugin.BaseTest.FAIL; 4 | 5 | import lombok.SneakyThrows; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.junit.runners.Parameterized; 9 | import org.junit.runners.Parameterized.Parameters; 10 | 11 | /** 12 | * 13 | * @author Rugal Bernstein 14 | */ 15 | @RunWith(Parameterized.class) 16 | public class MessageShowMojoFailOnErrorTest extends BaseTest { 17 | 18 | @Parameters 19 | public static String[] data() { 20 | return new String[]{ 21 | "failOnErrorFromSystemProperty" 22 | }; 23 | } 24 | 25 | /** 26 | * These tests should success. 27 | * 28 | * @throws Exception 29 | */ 30 | @SneakyThrows 31 | @Test 32 | public void caseSuccess() { 33 | System.setProperty("commitlinter.failOnError", "false"); 34 | System.out.println(String.format("%s on %s", SUCCESS, this.caseFormat)); 35 | this.getMojo("show", this.caseFormat, SUCCESS).execute(); 36 | } 37 | 38 | /** 39 | * These tests should fail. 40 | * 41 | * @throws Exception 42 | */ 43 | @SneakyThrows 44 | @Test 45 | public void caseFail() { 46 | System.setProperty("commitlinter.failOnError", "true"); 47 | System.out.println(String.format("%s on %s", FAIL, this.caseFormat)); 48 | this.getMojo("show", this.caseFormat, FAIL).execute(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/MessageShowMojoSkipTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import static ga.rugal.maven.plugin.BaseTest.FAIL; 4 | 5 | import lombok.SneakyThrows; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.junit.runners.Parameterized; 9 | import org.junit.runners.Parameterized.Parameters; 10 | 11 | /** 12 | * 13 | * @author Rugal Bernstein 14 | */ 15 | @RunWith(Parameterized.class) 16 | public class MessageShowMojoSkipTest extends BaseTest { 17 | 18 | @Parameters 19 | public static String[] data() { 20 | return new String[]{ 21 | "skipFromSystemProperty" 22 | }; 23 | } 24 | 25 | /** 26 | * These tests should success. 27 | * 28 | * @throws Exception 29 | */ 30 | @SneakyThrows 31 | @Test 32 | public void caseSuccess() { 33 | System.setProperty("commitlinter.skip", "true"); 34 | System.out.println(String.format("%s on %s", SUCCESS, this.caseFormat)); 35 | this.getMojo("show", this.caseFormat, SUCCESS).execute(); 36 | } 37 | 38 | /** 39 | * These tests should fail. 40 | */ 41 | @SneakyThrows 42 | @Test 43 | public void caseFail() { 44 | System.setProperty("commitlinter.skip", "false"); 45 | System.out.println(String.format("%s on %s", FAIL, this.caseFormat)); 46 | this.getMojo("show", this.caseFormat, FAIL).execute(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/MessageShowMojoXmlTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import lombok.SneakyThrows; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.junit.runners.Parameterized; 8 | import org.junit.runners.Parameterized.Parameters; 9 | 10 | /** 11 | * 12 | * @author Rugal Bernstein 13 | */ 14 | @RunWith(Parameterized.class) 15 | public class MessageShowMojoXmlTest extends BaseTest { 16 | 17 | @Parameters 18 | public static String[] data() { 19 | return new String[]{ 20 | "lowercase" 21 | }; 22 | } 23 | 24 | @Before 25 | public void setUp() { 26 | System.clearProperty("commitlinter.skip"); 27 | System.clearProperty("commitlinter.failOnError"); 28 | } 29 | 30 | /** 31 | * These tests should success. 32 | * 33 | * @throws Exception 34 | */ 35 | @SneakyThrows 36 | @Test 37 | public void caseSuccess() { 38 | System.out.println(String.format("%s on %s", SUCCESS, this.caseFormat)); 39 | this.getMojo("show", this.caseFormat, SUCCESS).execute(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/MessageValidatorMojoFailOnErrorTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import lombok.SneakyThrows; 4 | import org.apache.maven.plugin.MojoFailureException; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.junit.runners.Parameterized; 8 | import org.junit.runners.Parameterized.Parameters; 9 | 10 | /** 11 | * 12 | * @author Rugal Bernstein 13 | */ 14 | @RunWith(Parameterized.class) 15 | public class MessageValidatorMojoFailOnErrorTest extends BaseTest { 16 | 17 | @Parameters 18 | public static String[] data() { 19 | return new String[]{ 20 | "failOnErrorFromSystemProperty" 21 | }; 22 | } 23 | 24 | /** 25 | * These tests should success. 26 | * 27 | * @throws Exception 28 | */ 29 | @SneakyThrows 30 | @Test 31 | public void caseSuccess() { 32 | System.setProperty("commitlinter.failOnError", "false"); 33 | System.out.println(String.format("%s on %s", SUCCESS, this.caseFormat)); 34 | this.getMojo("validate", this.caseFormat, SUCCESS).execute(); 35 | } 36 | 37 | /** 38 | * These tests should fail. 39 | * 40 | * @throws Exception 41 | */ 42 | @Test(expected = MojoFailureException.class) 43 | @SneakyThrows 44 | public void caseFail() { 45 | System.setProperty("commitlinter.failOnError", "true"); 46 | System.out.println(String.format("%s on %s", FAIL, this.caseFormat)); 47 | this.getMojo("validate", this.caseFormat, FAIL).execute(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/MessageValidatorMojoSkipTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import lombok.SneakyThrows; 4 | import org.apache.maven.plugin.MojoFailureException; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.junit.runners.Parameterized; 8 | import org.junit.runners.Parameterized.Parameters; 9 | 10 | /** 11 | * 12 | * @author Rugal Bernstein 13 | */ 14 | @RunWith(Parameterized.class) 15 | public class MessageValidatorMojoSkipTest extends BaseTest { 16 | 17 | @Parameters 18 | public static String[] data() { 19 | return new String[]{ 20 | "skipFromSystemProperty" 21 | }; 22 | } 23 | 24 | /** 25 | * These tests should success. 26 | * 27 | * @throws Exception 28 | */ 29 | @SneakyThrows 30 | @Test 31 | public void caseSuccess() { 32 | System.setProperty("commitlinter.skip", "true"); 33 | System.out.println(String.format("%s on %s", SUCCESS, this.caseFormat)); 34 | this.getMojo("validate", this.caseFormat, SUCCESS).execute(); 35 | } 36 | 37 | /** 38 | * These tests should fail. 39 | * 40 | * @throws Exception 41 | */ 42 | @SneakyThrows 43 | @Test(expected = MojoFailureException.class) 44 | public void caseFail() { 45 | System.setProperty("commitlinter.skip", "false"); 46 | System.out.println(String.format("%s on %s", FAIL, this.caseFormat)); 47 | this.getMojo("validate", this.caseFormat, FAIL).execute(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/ga/rugal/maven/plugin/MessageValidatorMojoXmlTest.java: -------------------------------------------------------------------------------- 1 | package ga.rugal.maven.plugin; 2 | 3 | import lombok.SneakyThrows; 4 | import org.apache.maven.plugin.MojoFailureException; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.junit.runners.Parameterized; 9 | import org.junit.runners.Parameterized.Parameters; 10 | 11 | /** 12 | * 13 | * @author Rugal Bernstein 14 | */ 15 | @RunWith(Parameterized.class) 16 | public class MessageValidatorMojoXmlTest extends BaseTest { 17 | 18 | @Parameters 19 | public static String[] data() { 20 | return new String[]{ 21 | "lowercase", "uppercase", "uppercamelcase", "lowercamelcase", "sentencecase", "kebabcase", 22 | "snakecase", "none", "max", "min", "skip", "unmatch", "nocontent", "head", "gitfolder", 23 | "present", "past", "thirdparty" 24 | }; 25 | } 26 | 27 | @Before 28 | public void setUp() { 29 | System.clearProperty(Constant.SKIP); 30 | System.clearProperty(Constant.FAIL_ON_ERROR); 31 | } 32 | 33 | /** 34 | * These tests should success. 35 | * 36 | * @throws Exception 37 | */ 38 | @SneakyThrows 39 | @Test 40 | public void caseSuccess() { 41 | System.out.println(String.format("%s on %s", SUCCESS, this.caseFormat)); 42 | this.getMojo("validate", this.caseFormat, SUCCESS).execute(); 43 | } 44 | 45 | /** 46 | * These tests should fail. 47 | * 48 | * @throws Exception 49 | */ 50 | @SneakyThrows 51 | @Test(expected = MojoFailureException.class) 52 | public void caseFail() { 53 | System.out.println(String.format("%s on %s", FAIL, this.caseFormat)); 54 | this.getMojo("validate", this.caseFormat, FAIL).execute(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/resources/unittest/failOnErrorFromSystemProperty/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | LOWERCASE 27 | 28 | 29 | LOWERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/failOnErrorFromSystemProperty/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | LOWERCASE 27 | 28 | 29 | LOWERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/unittest/gitfolder/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | wrong 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/test/resources/unittest/gitfolder/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/test/resources/unittest/head/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | wrong 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/test/resources/unittest/head/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/test/resources/unittest/kebabcase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s-]*):([\w\s-]*) 22 | this_is_not_kebab_case:This is not kebab case Either 23 | true 24 | 25 | 26 | KEBABCASE 27 | 28 | 29 | KEBABCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/kebabcase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w-]*):([\w-]*) 22 | this-is-kebab-case:this-is-another-kebab-case 23 | true 24 | 25 | 26 | KEBABCASE 27 | 28 | 29 | KEBABCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/lowercamelcase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (\([\w\s-]+\)):([\w\s-]*):([\w\s]*) 22 | (This-Is-Not-Lower-Camel-Case):ThisIsNotLowerCamelCaseEither:This Is Not Lower Camel Case Either 23 | true 24 | 25 | 26 | LOWERCAMELCASE 27 | 28 | 29 | LOWERCAMELCASE 30 | 31 | 32 | LOWERCAMELCASE 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/test/resources/unittest/lowercamelcase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (\(\w*\))\s(\w*) 22 | (thisIsLowerCamelCase) thisIsLowerCamelCaseToo 23 | true 24 | 25 | 26 | LOWERCAMELCASE 27 | 28 | 29 | LOWERCAMELCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/lowercase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | LOWERCASE 27 | 28 | 29 | LOWERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/lowercase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | lowercase-123: this is lower case 23 | true 24 | 25 | 26 | LOWERCASE 27 | 28 | 29 | LOWERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/max/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | 10 27 | 28 | 29 | 15 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/max/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | lowercase-123: this is lower case 23 | true 24 | 25 | 26 | 20 27 | 28 | 29 | 20 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/min/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | 30 27 | 28 | 29 | 25 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/min/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | lowercase-123: this is lower case 23 | true 24 | 25 | 26 | 5 27 | 28 | 29 | 5 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/nocontent/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (!+) 22 | !!! 23 | true 24 | 25 | 26 | 10 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/nocontent/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | .* 22 | lowercase-123: this is lower case 23 | true 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/unittest/none/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w-]*) 22 | this-is-any-case 23 | true 24 | 25 | 26 | NONE 27 | 1 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/test/resources/unittest/none/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w-]*) 22 | this-is-any-case 23 | false 24 | 25 | 26 | NONE 27 | 1 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/test/resources/unittest/past/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | Add new feature 22 | true 23 | 24 | 25 | PAST 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/past/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | Added new feature 22 | true 23 | 24 | 25 | PAST 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/present/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | Added new feature 22 | true 23 | 24 | 25 | PRESENT 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/present/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | Add new feature 22 | true 23 | 24 | 25 | PRESENT 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/sentencecase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (\([\w\s]*\)):([\w\s]*) 22 | (this is not sentence case):THIS IS NOT SENTENCE CASE EITHER 23 | true 24 | 25 | 26 | SENTENCECASE 27 | 28 | 29 | SENTENCECASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/sentencecase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (\([\w\s]*\)):([\w\s]*) 22 | (This is sentence case):This is also sentence case 23 | true 24 | 25 | 26 | SENTENCECASE 27 | 28 | 29 | SENTENCECASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/skip/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | 10 27 | 28 | 29 | 15 30 | 31 | 32 | false 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/unittest/skip/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | 10 27 | 28 | 29 | 15 30 | 31 | 32 | true 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/unittest/skipFromSystemProperty/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | LOWERCASE 27 | 28 | 29 | LOWERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/skipFromSystemProperty/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | NotLowerCase-123: ThisIsNotLowerCase 23 | true 24 | 25 | 26 | LOWERCASE 27 | 28 | 29 | LOWERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/unittest/snakecase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s-_]*):([\w\s-_]*) 22 | this-is-not-snake-case:This is not snake case Either 23 | true 24 | 25 | 26 | SNAKECASE 27 | 28 | 29 | SNAKECASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/snakecase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w_]*):([\w_]*) 22 | this_is_kebab_case:this_is_another_kebab_case 23 | true 24 | 25 | 26 | SNAKECASE 27 | 28 | 29 | SNAKECASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/thirdparty/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | Add new feature 22 | true 23 | 24 | 25 | THIRD_PARTY 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/thirdparty/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | Adds new feature 22 | true 23 | 24 | 25 | THIRD_PARTY 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/resources/unittest/unmatch/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | \(.*\) 22 | lowercase-123: this is lower case 23 | true 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/unittest/unmatch/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | .* 22 | lowercase-123: this is lower case 23 | true 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/unittest/uppercamelcase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (\([\w\s]*\))\s(\w*):([\w\s]*) 22 | (thisIsNotUpperCamelCase) this_Is_Not_Upper_Camel_Case_Too:This Is Not Lower Camel Case Either 23 | true 24 | 25 | 26 | UPPERCAMELCASE 27 | 28 | 29 | UPPERCAMELCASE 30 | 31 | 32 | UPPERCAMELCASE 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/test/resources/unittest/uppercamelcase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | (\(\w*\))\s(\w*) 22 | (ThisIsUpperCamelCase) ThisIsUpperCamelCaseToo 23 | true 24 | 25 | 26 | UPPERCAMELCASE 27 | 28 | 29 | UPPERCAMELCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/uppercase/fail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | test-123: add some data 23 | true 24 | 25 | 26 | UPPERCASE 27 | 28 | 29 | UPPERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/unittest/uppercase/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | ga.rugal.maven 5 | commitlinter-maven-plugin-test 6 | 1.0-SNAPSHOT 7 | maven-plugin 8 | Git Commit Message Linter Maven Plugin Test 9 | 10 | UTF-8 11 | 1.8 12 | 1.8 13 | 14 | 15 | 16 | 17 | ga.rugal.maven 18 | commitlinter-maven-plugin 19 | 1.0-SNAPSHOT 20 | 21 | ([\w\s]+-\d+:\s)(.*) 22 | TEST-123: ADD SOME DATA 23 | true 24 | 25 | 26 | UPPERCASE 27 | 28 | 29 | UPPERCASE 30 | 31 | 32 | 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------