public class GitVersionCalculator extends Object implements AutoCloseable, MetadataProvider
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
String |
getVersion()
Calculates the version to use for the current git repository depending on the HEAD position.
|
Version |
getVersionObject()
Calculates the version to use for the current git repository depending on the HEAD position.
|
static GitVersionCalculator |
location(File gitRepositoryLocation)
Creates a
GitVersionCalculator for the git repository pointing to the given path. |
Optional<String> |
meta(Metadatas meta) |
GitVersionCalculator |
setAutoIncrementPatch(boolean value)
When true, when the found tag to calculate a version for HEAD is a normal/annotated one, the semver patch version
of the tag is increased by one ; except when the tag is on the HEAD itself.
|
GitVersionCalculator |
setFindTagVersionPattern(String pattern)
Defines a regexp search pattern that will match tags identifying a version.
|
GitVersionCalculator |
setGitCommitIdLength(int gitCommitIdLength)
Defines how long the qualifier from SHA1 git commit has to be.
|
GitVersionCalculator |
setMavenLike(boolean mavenLike)
Activates the maven like mode.
|
GitVersionCalculator |
setNonQualifierBranches(String nonQualifierBranches)
Defines a comma separated list of branches for which no branch name qualifier will be used. default "master".
|
GitVersionCalculator |
setQualifierBranchingPolicies(BranchingPolicy... policies)
Sets as an array the policies that will be applied to try to build a qualifier from the branch of the HEAD.
|
GitVersionCalculator |
setQualifierBranchingPolicies(List<BranchingPolicy> policies)
Sets as a list the policies that will be applied to try to build a qualifier from the branch of the HEAD.
|
GitVersionCalculator |
setUseDefaultBranchingPolicy(boolean useDefaultBranchingPolicy)
When true, uses
BranchingPolicy.DEFAULT_FALLBACK as last BranchingPolicy. |
GitVersionCalculator |
setUseDirty(boolean useDirty)
When true, append a qualifier with the "dirty" qualifier if the repository is in a dirty state (ie with
uncommited changes or new files)
|
GitVersionCalculator |
setUseDistance(boolean useDistance)
When true, append a qualifier with the distance between the HEAD commit and the found commit with a version tag.
|
GitVersionCalculator |
setUseGitCommitId(boolean useGitCommitId)
When true, append the git commit id (SHA1) to the version.
|
GitVersionCalculator |
setUseGitCommitTimestamp(boolean useGitCommitTimestamp)
When true, append the git commit timestamp to the version.
|
GitVersionCalculator |
setUseLongFormat(boolean useLongFormat)
When true describes commits hash with long format pattern, ie preceded with the letter 'g'.
|
public static GitVersionCalculator location(File gitRepositoryLocation)
GitVersionCalculator for the git repository pointing to the given path.gitRepositoryLocation - the location of the git repository to find version forGitVersionCalculatorpublic Version getVersionObject()
public String getVersion()
public void close()
throws Exception
close in interface AutoCloseableExceptionpublic GitVersionCalculator setAutoIncrementPatch(boolean value)
value - if true and when found tag is not on HEAD, then version returned will be the found version with
patch number increased by one. default false.public GitVersionCalculator setNonQualifierBranches(String nonQualifierBranches)
setQualifierBranchingPolicies(List) &
setQualifierBranchingPolicies(BranchingPolicy...).nonQualifierBranches - a comma separated list of branch name for which no branch name qualifier should be
used, can be null and/or emptypublic GitVersionCalculator setQualifierBranchingPolicies(BranchingPolicy... policies)
setNonQualifierBranches(String) & setQualifierBranchingPolicies(List).policies - an array of policies to apply can be emptypublic GitVersionCalculator setQualifierBranchingPolicies(List<BranchingPolicy> policies)
setNonQualifierBranches(String) &
setQualifierBranchingPolicies(BranchingPolicy...).policies - an array of policies to apply can be emptypublic GitVersionCalculator setUseDistance(boolean useDistance)
useDistance - if true, a qualifier with found distance will be used.public GitVersionCalculator setUseDirty(boolean useDirty)
useDirty - if true, a qualifier with "dirty" qualifier will be used if the repository is stall.public GitVersionCalculator setUseLongFormat(boolean useLongFormat)
useLongFormat - if true and useGitCommitId,
then commitId will be prepended with a 'g' to be compliant with `git describe --long` formatpublic GitVersionCalculator setUseGitCommitId(boolean useGitCommitId)
useGitCommitId - if true, a qualifier with SHA1 git commit will be used, default truepublic GitVersionCalculator setUseGitCommitTimestamp(boolean useGitCommitTimestamp)
useGitCommitTimestamp - if true, a qualifier with git commit timestamp will be used, default falsepublic GitVersionCalculator setUseDefaultBranchingPolicy(boolean useDefaultBranchingPolicy)
BranchingPolicy.DEFAULT_FALLBACK as last BranchingPolicy.useDefaultBranchingPolicy - if true, appends BranchingPolicy.DEFAULT_FALLBACK as last branching policypublic GitVersionCalculator setGitCommitIdLength(int gitCommitIdLength)
gitCommitIdLength - the length of the SHA1 substring to use as qualifier, valid values [8, 40], default 8IllegalArgumentException - in case the length is not in the range [8,40]public GitVersionCalculator setMavenLike(boolean mavenLike)
mavenLike - true to activate maven like modepublic GitVersionCalculator setFindTagVersionPattern(String pattern)
pattern - a non null string representing a java regexp pattern able to match tag containing versionsPatternSyntaxException - if the given string cannot be parsed
as a correct Pattern objectpublic Optional<String> meta(Metadatas meta)
meta in interface MetadataProviderCopyright © 2016–2018 Matthieu Brouillard. All rights reserved.