Skip to content

Commit fde0620

Browse files
author
S L
committed
#211 : Use a enum for different configuration options
1 parent a2e5494 commit fde0620

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This file is part of git-commit-id-plugin by Konrad 'ktoso' Malawski <[email protected]>
3+
*
4+
* git-commit-id-plugin is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* git-commit-id-plugin is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with git-commit-id-plugin. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package pl.project13.maven.git;
18+
19+
public enum CommitIdGenerationModeEnum{
20+
FULL,
21+
FLAT,
22+
UNKNOWN;
23+
24+
public static CommitIdGenerationModeEnum getValue(String o){
25+
if(o != null){
26+
for(CommitIdGenerationModeEnum v : values()){
27+
if(v.name().toString().equalsIgnoreCase(o)){
28+
return v;
29+
}
30+
}
31+
}
32+
return CommitIdGenerationModeEnum.UNKNOWN;
33+
}
34+
}

src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,13 @@ public void execute() throws MojoExecutionException {
404404
}
405405

406406
try {
407-
if(commitIdGenerationMode == null){
408-
commitIdGenerationMode = "flat";
409-
}
410-
switch(commitIdGenerationMode.toLowerCase()){
407+
switch(CommitIdGenerationModeEnum.getValue(commitIdGenerationMode)){
411408
default:
412409
loggerBridge.warn("Detected wrong setting for 'commitIdGenerationMode' will fallback to default 'flat'-Mode!");
413-
case "flat":
410+
case FLAT:
414411
COMMIT_ID = COMMIT_ID_FLAT;
415412
break;
416-
case "full":
413+
case FULL:
417414
COMMIT_ID = COMMIT_ID_FULL;
418415
break;
419416
}

0 commit comments

Comments
 (0)