@@ -66,6 +66,7 @@ public class GitCommitIdMojo extends AbstractMojo {
6666 public static final String COMMIT_ID = "commit.id" ;
6767 public static final String COMMIT_ID_ABBREV = "commit.id.abbrev" ;
6868 public static final String COMMIT_DESCRIBE = "commit.id.describe" ;
69+ public static final String COMMIT_SHORT_DESCRIBE = "commit.id.short-describe" ;
6970 public static final String BUILD_AUTHOR_NAME = "build.user.name" ;
7071 public static final String BUILD_AUTHOR_EMAIL = "build.user.email" ;
7172 public static final String BUILD_TIME = "build.time" ;
@@ -205,7 +206,7 @@ public class GitCommitIdMojo extends AbstractMojo {
205206 */
206207 @ SuppressWarnings ("UnusedDeclaration" )
207208 private String prefix ;
208- private String prefixDot ;
209+ private String prefixDot = "" ;
209210
210211 /**
211212 * The date format to be used for any dates exported by this plugin.
@@ -308,6 +309,7 @@ public void execute() throws MojoExecutionException {
308309
309310 loadGitData (properties );
310311 loadBuildTimeData (properties );
312+ loadShortDescribe (properties );
311313 filterNot (properties , excludeProperties );
312314 logProperties (properties );
313315
@@ -419,6 +421,27 @@ void loadBuildTimeData(@NotNull Properties properties) {
419421 SimpleDateFormat smf = new SimpleDateFormat (dateFormat );
420422 put (properties , BUILD_TIME , smf .format (commitDate ));
421423 }
424+
425+ void loadShortDescribe (@ NotNull Properties properties ) {
426+ //removes git hash part from describe
427+ String commitDescribe = properties .getProperty (prefixDot + COMMIT_DESCRIBE );
428+
429+ if (commitDescribe != null ) {
430+ int startPos = commitDescribe .indexOf ("-g" );
431+ if (startPos > 0 ) {
432+ String commitShortDescribe ;
433+ int endPos = commitDescribe .indexOf ('-' , startPos + 1 );
434+ if (endPos < 0 ) {
435+ commitShortDescribe = commitDescribe .substring (0 , startPos );
436+ } else {
437+ commitShortDescribe = commitDescribe .substring (0 , startPos ) + commitDescribe .substring (endPos );
438+ }
439+ put (properties , COMMIT_SHORT_DESCRIBE , commitShortDescribe );
440+ } else {
441+ put (properties , COMMIT_SHORT_DESCRIBE , commitDescribe );
442+ }
443+ }
444+ }
422445
423446 void loadGitData (@ NotNull Properties properties ) throws IOException , MojoExecutionException {
424447 Repository git = getGitRepository ();
0 commit comments