Locates the nearest org.ajoberstar.grgit.Tags whose names can be parsed as a com.github.zafarkhaja.semver.Version. Both the absolute nearest version tag and the nearest "normal version" tag are included.
Primarily used as part of version inference to determine the previous version.
Type | Name and description |
---|---|
TagStrategy |
strategy |
Constructor and description |
---|
NearestVersionLocator
(TagStrategy strategy) |
Type | Name and description |
---|---|
NearestVersion |
locate(Grgit grgit) Locate the nearest version in the given repository starting from the current HEAD. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Locate the nearest version in the given repository starting from the current HEAD.
All tag names are parsed to determine if they are valid version strings. Tag names can begin with "v" (which will be stripped off).
The nearest tag is determined by getting a commit log between
the tag and HEAD
. The version tag with the smallest
log from a pure count of commits will have its version returned. If two
version tags have a log of the same size, the versions will be compared
to find the one with the highest precedence according to semver rules.
For example, 1.0.0
has higher precedence than 1.0.0-rc.2
.
For tags with logs of the same size and versions of the same precedence
it is undefined which will be returned.
Two versions will be returned: the "any" version and the "normal" version. "Any" is the absolute nearest tagged version. "Normal" is the nearest tagged version that does not include a pre-release segment.
grgit
- the repository to locate the tag infromRevStr
- the revision to consider current.
Defaults to HEAD
.Groovy Documentation