From e3f7ec375b0cbac378163882a47a81ee3cd3ebc8 Mon Sep 17 00:00:00 2001 From: S L Date: Mon, 21 Jul 2014 23:50:22 +0200 Subject: [PATCH 1/5] rm orig-MergeFile --- .../GitCommitIdMojoIntegrationTest.java.orig | 414 ------------------ 1 file changed, 414 deletions(-) delete mode 100644 src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java.orig diff --git a/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java.orig b/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java.orig deleted file mode 100644 index 3a30b339..00000000 --- a/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java.orig +++ /dev/null @@ -1,414 +0,0 @@ -/* - * This file is part of git-commit-id-plugin by Konrad Malawski - * - * git-commit-id-plugin is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * git-commit-id-plugin is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with git-commit-id-plugin. If not, see . - */ - -package pl.project13.maven.git; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import java.util.Arrays; -import java.util.Collection; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.io.Files; -import pl.project13.maven.git.FileSystemMavenSandbox.CleanUp; -import pl.project13.test.utils.AssertException; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import static org.fest.assertions.Assertions.assertThat; -import static org.fest.assertions.MapAssert.entry; -import static org.mockito.internal.util.reflection.Whitebox.setInternalState; - -@RunWith(JUnitParamsRunner.class) -public class GitCommitIdMojoIntegrationTest extends GitIntegrationTest { - - public static Collection defaultParameter() { - return Arrays.asList(new Object[] { - Boolean.FALSE, - Boolean.TRUE - }); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldResolvePropertiesOnDefaultSettingsForNonPomProject(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-jar-project", "jar").withNoChildProject().withGitRepoInParent(AvailableGitTestRepo.WITH_ONE_COMMIT).create(CleanUp.CLEANUP_FIRST); - MavenProject targetProject = mavenSandbox.getParentProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertGitPropertiesPresentInProject(targetProject.getProperties()); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldNotRunWhenSkipIsSet(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-skip-project", "jar").withNoChildProject().withGitRepoInParent(AvailableGitTestRepo.WITH_ONE_COMMIT).create(CleanUp.CLEANUP_FIRST); - MavenProject targetProject = mavenSandbox.getParentProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("skip", Boolean.TRUE); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).isEmpty(); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldNotRunWhenPackagingPomAndDefaultSettingsApply(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom").withNoChildProject().withGitRepoInParent(AvailableGitTestRepo.WITH_ONE_COMMIT).create(CleanUp.CLEANUP_FIRST); - MavenProject targetProject = mavenSandbox.getParentProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).isEmpty(); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldRunWhenPackagingPomAndSkipPomsFalse(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom").withNoChildProject().withGitRepoInParent(AvailableGitTestRepo.WITH_ONE_COMMIT).create(CleanUp.CLEANUP_FIRST); - MavenProject targetProject = mavenSandbox.getParentProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("skipPoms", false); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).isNotEmpty(); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldUseParentProjectRepoWhenInvokedFromChild(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom").withChildProject("my-jar-module", "jar").withGitRepoInParent(AvailableGitTestRepo.WITH_ONE_COMMIT).create(CleanUp.CLEANUP_FIRST); - MavenProject targetProject = mavenSandbox.getChildProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("skipPoms", false); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertGitPropertiesPresentInProject(targetProject.getProperties()); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldUseChildProjectRepoIfInvokedFromChild(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom").withChildProject("my-jar-module", "jar").withGitRepoInChild(AvailableGitTestRepo.WITH_ONE_COMMIT).create(CleanUp.CLEANUP_FIRST); - MavenProject targetProject = mavenSandbox.getChildProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("skipPoms", false); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertGitPropertiesPresentInProject(targetProject.getProperties()); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldFailWithExceptionWhenNoGitRepoFound(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withNoGitRepoAvailable() - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("skipPoms", false); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - AssertException.CodeBlock block = new AssertException.CodeBlock() { - @Override - public void run() throws Exception { - mojo.execute(); - } - }; - - // then - AssertException.thrown(MojoExecutionException.class, block); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldGenerateCustomPropertiesFileProperties(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.GIT_COMMIT_ID) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - - String targetFilePath = "target/classes/custom-git.properties"; - File expectedFile = new File(targetProject.getBasedir(), targetFilePath); - - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("generateGitPropertiesFile", true); - alterMojoSettings("generateGitPropertiesFilename", targetFilePath); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - try { - mojo.execute(); - - // then - assertThat(expectedFile).exists(); - } finally { - FileUtils.forceDelete(expectedFile); - } - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldGenerateCustomPropertiesFileJson(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.GIT_COMMIT_ID) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - - String targetFilePath = "target/classes/custom-git.properties"; - File expectedFile = new File(targetProject.getBasedir(), targetFilePath); - - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("generateGitPropertiesFile", true); - alterMojoSettings("generateGitPropertiesFilename", targetFilePath); - alterMojoSettings("format", "json"); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - try { - mojo.execute(); - - // then - assertThat(expectedFile).exists(); - String json = Files.toString(expectedFile, Charset.defaultCharset()); - ObjectMapper om = new ObjectMapper(); - Map map = new HashMap(); - map = om.readValue(expectedFile, map.getClass()); - assertThat(map.size() > 10); - } finally { - FileUtils.forceDelete(expectedFile); - } - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldSkipWithoutFailOnNoGitDirectoryWhenNoGitRepoFound(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-jar-project", "jar") - .withNoChildProject() - .withNoGitRepoAvailable() - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getParentProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("failOnNoGitDirectory", false); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).isEmpty(); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldNotSkipWithoutFailOnNoGitDirectoryWhenNoGitRepoIsPresent(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-jar-project", "jar") - .withNoChildProject() - .withGitRepoInParent(AvailableGitTestRepo.WITH_ONE_COMMIT) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getParentProject(); - setProjectToExecuteMojoIn(targetProject); - alterMojoSettings("failOnNoGitDirectory", false); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertGitPropertiesPresentInProject(targetProject.getProperties()); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalse(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.ON_A_TAG) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - - setProjectToExecuteMojoIn(targetProject); - GitDescribeConfig gitDescribeConfig = createGitDescribeConfig(false,7); - alterMojoSettings("gitDescribe", gitDescribeConfig); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe", "v1.0.0")); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldGenerateDescribeWithTagOnlyWhenForceLongFormatIsFalseAndAbbrevLengthIsNonDefault(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.ON_A_TAG) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - - setProjectToExecuteMojoIn(targetProject); - GitDescribeConfig gitDescribeConfig = createGitDescribeConfig(false,10); - alterMojoSettings("gitDescribe", gitDescribeConfig); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe", "v1.0.0")); - assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe-short", "v1.0.0")); - } - - @Test - @Parameters(method = "defaultParameter") - public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIsTrue(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.ON_A_TAG) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - - setProjectToExecuteMojoIn(targetProject); - GitDescribeConfig gitDescribeConfig = createGitDescribeConfig(true,7); - alterMojoSettings("gitDescribe", gitDescribeConfig); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe", "v1.0.0-0-gde4db35")); - assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe-short", "v1.0.0-0")); - } -<<<<<<< HEAD - -======= - - @Test - @Parameters(method = "defaultParameter") - public void shouldGenerateDescribeWithTagAndZeroAndCommitIdWhenForceLongFormatIsTrueAndAbbrevLengthIsNonDefault(boolean useNativeGit) throws Exception { - // given - mavenSandbox.withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.ON_A_TAG) - .create(CleanUp.CLEANUP_FIRST); - - MavenProject targetProject = mavenSandbox.getChildProject(); - - setProjectToExecuteMojoIn(targetProject); - GitDescribeConfig gitDescribeConfig = createGitDescribeConfig(true,10); - alterMojoSettings("gitDescribe", gitDescribeConfig); - alterMojoSettings("useNativeGit", useNativeGit); - - // when - mojo.execute(); - - // then - assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe", "v1.0.0-0-gde4db35")); - } - - private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev){ - GitDescribeConfig gitDescribeConfig = new GitDescribeConfig(); - gitDescribeConfig.setTags(true); - gitDescribeConfig.setForceLongFormat(forceLongFormat); - gitDescribeConfig.setAbbrev(abbrev); - return gitDescribeConfig; - } - ->>>>>>> Added some tests which modify the abbrev length of the git.discribe to identify problems with the native git thingy - private void alterMojoSettings(String parameterName, Object parameterValue) { - setInternalState(mojo, parameterName, parameterValue); - } - - private void assertGitPropertiesPresentInProject(Properties properties) { - assertThat(properties).satisfies(new ContainsKeyCondition("git.build.time")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.branch")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.id")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.id.abbrev")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.build.user.name")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.build.user.email")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.user.name")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.user.email")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.message.full")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.message.short")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.commit.time")); - assertThat(properties).satisfies(new ContainsKeyCondition("git.remote.origin.url")); - } -} From 0eb3694e4d3976a861cebc9044b976ce8cc96af7 Mon Sep 17 00:00:00 2001 From: S L Date: Tue, 22 Jul 2014 00:48:40 +0200 Subject: [PATCH 2/5] https://github.com/ktoso/maven-git-commit-id-plugin/issues/97 : Extend git-plugin with --match Option for describe --- .../maven/git/GitDescribeConfig.java | 2 ++ .../maven/git/NativeGitProvider.java | 7 +++- .../git/GitCommitIdMojoIntegrationTest.java | 34 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/java/pl/project13/maven/git/GitDescribeConfig.java b/src/main/java/pl/project13/maven/git/GitDescribeConfig.java index 1d48ad33..a5dc0848 100644 --- a/src/main/java/pl/project13/maven/git/GitDescribeConfig.java +++ b/src/main/java/pl/project13/maven/git/GitDescribeConfig.java @@ -148,6 +148,8 @@ public class GitDescribeConfig { * since tag v1.2 that points at object deadbee....). *

*

false
by default. + * + * @parameter default-value=false */ private boolean forceLongFormat; diff --git a/src/main/java/pl/project13/maven/git/NativeGitProvider.java b/src/main/java/pl/project13/maven/git/NativeGitProvider.java index af789105..eb454c47 100644 --- a/src/main/java/pl/project13/maven/git/NativeGitProvider.java +++ b/src/main/java/pl/project13/maven/git/NativeGitProvider.java @@ -128,11 +128,16 @@ private String getArgumentsForGitDescribeAndDescibeNotNull(GitDescribeConfig git String dirtyMark = gitDescribe.getDirty(); if (dirtyMark != null && !dirtyMark.isEmpty()) { - // Option: --dirty[=] // TODO: Code Injection? Or does the CliRunner escape Arguments? argumentsForGitDescribe.append("--dirty=" + dirtyMark + " "); } + String matchOption = gitDescribe.getMatch(); + if (matchOption != null && !matchOption.isEmpty()) { + // TODO: Code Injection? Or does the CliRunner escape Arguments? + argumentsForGitDescribe.append("--match=" + matchOption + " "); + } + argumentsForGitDescribe.append("--abbrev=" + gitDescribe.getAbbrev() + " "); if (gitDescribe.getTags()) { diff --git a/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java b/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java index c8239a3f..520b2391 100644 --- a/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java +++ b/src/test/java/pl/project13/maven/git/GitCommitIdMojoIntegrationTest.java @@ -565,6 +565,40 @@ public void shouldWorkWithNullGitDescribe(boolean useNativeGit) throws Exception assertGitPropertiesPresentInProject(targetProject.getProperties()); } + @Test + @Parameters(method = "useNativeGit") + public void runGitDescribeWithMatchOption(boolean useNativeGit) throws Exception { + // given + mavenSandbox.withParentProject("my-pom-project", "pom") + .withChildProject("my-jar-module", "jar") + .withGitRepoInChild(AvailableGitTestRepo.MAVEN_GIT_COMMIT_ID_PLUGIN) + .create(CleanUp.CLEANUP_FIRST); + MavenProject targetProject = mavenSandbox.getChildProject(); + + setProjectToExecuteMojoIn(targetProject); + + Map gitTagMap = new HashMap(); + gitTagMap.put("v2.1.8", "4f787aa37d5d9c06780278f0cf92553d304820a2"); + gitTagMap.put("v2.1.9", "a9dba4a25b64ab288d90cd503785b830d2e189a2"); + + for (Map.Entry entry : gitTagMap.entrySet()) { + String gitDescribeMatchNeedle = entry.getKey(); + String commitIdOfMatchNeedle = entry.getValue(); + + GitDescribeConfig gitDescribeConfig = new GitDescribeConfig(); + gitDescribeConfig.setMatch(gitDescribeMatchNeedle); + alterMojoSettings("gitDescribe", gitDescribeConfig); + alterMojoSettings("useNativeGit", useNativeGit); + + // when + mojo.execute(); + + // then + assertThat(targetProject.getProperties()).includes(entry("git.commit.id.describe", gitDescribeMatchNeedle)); + assertThat(targetProject.getProperties().get("git.commit.id")).isNotEqualTo(commitIdOfMatchNeedle); + } + } + private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev) { GitDescribeConfig gitDescribeConfig = new GitDescribeConfig(); gitDescribeConfig.setTags(true); From 034d865e8ee82b3bc82db25f32e0555c5b4e0183 Mon Sep 17 00:00:00 2001 From: S L Date: Tue, 22 Jul 2014 01:05:04 +0200 Subject: [PATCH 3/5] Updated readme and default-Pom-Configuration --- README.md | 9 +++++++-- pom.xml | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 738d1ac1..d5bb94b8 100644 --- a/README.md +++ b/README.md @@ -529,12 +529,16 @@ Optional parameters: * **dateFormat** - `(default: dd.MM.yyyy '@' HH:mm:ss z)` is a normal SimpleDateFormat String and will be used to represent git.build.time and git.commit.time * **verbose** - `(default: false)` if true the plugin will print a summary of all collected properties when it's done * **generateGitPropertiesFile** -`(default: false)` this is false by default, forces the plugin to generate the git.properties file -* **generateGitPropertiesFilename** - `(default: src/main/resources/git.properties)` - The path for the to be generated properties file, it's relative to ${project.basedir} +* **generateGitPropertiesFilename** - `(default: ${project.build.outputDirectory}/git.properties)` - The path for the file to be generated properties file can be relative to ${project.basedir} or can be a full path * **skipPoms** - `(default: true)` - Force the plugin to run even if you're inside of an pom packaged project. * **failOnNoGitDirectory** - `(default: true)` *(available since v2.0.4)* - Specify whether the plugin should fail when a .git directory can not be found. When set to false and no .git directory is found the plugin will skip execution. +* **failOnUnableToExtractRepoInfo** - `(default: true)` By default the plugin will fail the build if unable to obtain enough data for a complete run, if you don't care about this, you may want to set this value to false. * **skip** - `(default: false)` *(available since v2.1.8)* - Skip the plugin execution completely. * **excludeProperties** - `(default: empty)` *(available since v2.1.9)* - Allows to filter out properties that you *don't* want to expose. This feature was implemented in response to [this issue](https://github.com/ktoso/maven-git-commit-id-plugin/issues/91), so if you're curious about the use-case, check that issue. * **useNativeGit** - `(default: false)` *(available since v2.1.10)* - Uses the native `git` binary instead of the custom `jgit` implementation shipped with this plugin to obtain all information. Although this should usualy give your build some performance boost, it may randomly break if you upgrade your git version and it decides to print information in a different format suddenly. As rule of thumb, keep using the default `jgit` implementation (keep this option set to `false`) until you notice performance problems within your build (usualy when you have *hundreds* of maven modules). +* **abbrevLength** - `(default: 7)` Configure the "git.commit.id.abbrev" property to be at least of length N (see gitDescribe abbrev for special case abbrev = 0). +* **format** - `(default: properties)` The format to save properties in. Valid options are "properties" (default) and "json". Properties will be saved to the generateGitPropertiesFilename if generateGitPropertiesFile is set to `true`. + **gitDescribe**: Worth pointing out is, that git-commit-id tries to be 1-to-1 compatible with git's plain output, even though the describe functionality has been reimplemented manually using JGit (you don't have to have a git executable to use the plugin). So if you're familiar with [git-describe](https://github.com/ktoso/maven-git-commit-id-plugin#git-describe---short-intro-to-an-awesome-command), you probably can skip this section, as it just explains the same options that git provides. @@ -542,7 +546,8 @@ Worth pointing out is, that git-commit-id tries to be 1-to-1 compatible with git * **abbrev** - `(default: 7)` in the describe output, the object id of the hash is always abbreviated to N letters, by default 7. The typical describe output you'll see therefore is: `v2.1.0-1-gf5cd254`, where `-1-` means the number of commits away from the mentioned tag and the `-gf5cd254` part means the first 7 chars of the current commit's id `f5cd254`. **Please note that the `g` prefix is included to notify you that it's a commit id, it is NOT part of the commit's object id** - *this is default git bevaviour, so we're doing the same*. You can set this to any value between 0 and 40 (inclusive). * **abbrev = 0** is a special case. Setting *abbrev* to `0` has the effect of hiding the "distance from tag" and "object id" parts of the output, so you endup with just the "nearest tag" (that is, instead `tag-12-gaaaaaaa` with `abbrev = 0` you'd get `tag`). * **dirty** - `(default: "")` when you run describe on a repository that's in "dirty state" (has uncommited changes), the describe output will contain an additional suffix, such as "-devel" in this example: `v3.5-3-g2222222-devel`. You can configure that suffix to be anything you want, "-DEV" being a nice example. The "-" sign should be inclided in the configuration parameter, as it will not be added automatically. If in doubt run `git describe --dirty=-my_thing` to see how the end result will look like. -* **tags** - `(default: false)` +* **tags** - `(default: false)` if true this option enables matching a lightweight (non-annotated) tag. +* **match** - `(default: *)` only consider tags matching the given pattern (can be used to avoid leaking private tags made from the repository) * **long** - `(default: false)` git-describe, by default, returns just the tag name, if the current commit is tagged. Use this option to force it to format the output using the typical describe format. An example would be: `tagname-0-gc0ffebabe` - notice that the distance from the tag is 0 here, if you don't use **forceLongFormat** mode, the describe for such commit would look like this: `tagname`. * **always** - `(default: true)` if unable to find a tag, print out just the object id of the current commit. Useful when you always want to return something meaningful in the describe property. * **skip** - `(default: false)` when you don't use `git-describe` information in your build, you can opt to be calculate it. diff --git a/pom.xml b/pom.xml index 841a5d2b..5cbd1781 100644 --- a/pom.xml +++ b/pom.xml @@ -222,6 +222,7 @@ + From 6900568585acf88ef80a7e8d4e11d92214a4465f Mon Sep 17 00:00:00 2001 From: S L Date: Tue, 22 Jul 2014 01:08:47 +0200 Subject: [PATCH 4/5] improved generateGitPropertiesFilename-README Section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5bb94b8..b0c76769 100644 --- a/README.md +++ b/README.md @@ -529,7 +529,7 @@ Optional parameters: * **dateFormat** - `(default: dd.MM.yyyy '@' HH:mm:ss z)` is a normal SimpleDateFormat String and will be used to represent git.build.time and git.commit.time * **verbose** - `(default: false)` if true the plugin will print a summary of all collected properties when it's done * **generateGitPropertiesFile** -`(default: false)` this is false by default, forces the plugin to generate the git.properties file -* **generateGitPropertiesFilename** - `(default: ${project.build.outputDirectory}/git.properties)` - The path for the file to be generated properties file can be relative to ${project.basedir} or can be a full path +* **generateGitPropertiesFilename** - `(default: ${project.build.outputDirectory}/git.properties)` - The path for the to be generated properties file. The path can be relative to ${project.basedir} (e.g. target/classes/git.properties) or can be a full path (e.g. ${project.build.outputDirectory}/git.properties). * **skipPoms** - `(default: true)` - Force the plugin to run even if you're inside of an pom packaged project. * **failOnNoGitDirectory** - `(default: true)` *(available since v2.0.4)* - Specify whether the plugin should fail when a .git directory can not be found. When set to false and no .git directory is found the plugin will skip execution. * **failOnUnableToExtractRepoInfo** - `(default: true)` By default the plugin will fail the build if unable to obtain enough data for a complete run, if you don't care about this, you may want to set this value to false. From 60cb9786273940d6a1b9310f8da4a839491ff51a Mon Sep 17 00:00:00 2001 From: S L Date: Mon, 28 Jul 2014 20:22:47 +0200 Subject: [PATCH 5/5] Added match-Pattern to example Configuration in README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b0c76769..3a27170d 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,10 @@ It's really simple to setup this plugin; below is a sample pom that you may base -dirty - + + + * +