Skip to content

Commit b97ed88

Browse files
committed
Added argument pass-through for git describe (tag filtering)
1 parent 8fb3f19 commit b97ed88

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ In your `build.gradle` file:
1818
}
1919
// optionally: ext.nextVersion = "major", "minor" (default), "patch" or e.g. "3.0.0-rc2"
2020
// optionally: ext.snapshotSuffix = "SNAPSHOT" (default) or a pattern, e.g. "<count>.g<sha>-SNAPSHOT"
21+
// optionally: ext.gitDescribeArgs = '--match *[0-9].[0-9]*.[0-9]*' (default) or other arguments for git describe.
2122
apply plugin: 'com.cinnober.gradle.semver-git'
2223

2324
Note: Use this method instead of the newer `plugins` method if you want to change `nextVersion` and `snapshotSuffix`.

src/main/groovy/com/cinnober/gradle/semver_git/SemverGitPlugin.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ import org.gradle.api.Plugin
2929

3030
class SemverGitPlugin implements Plugin<Project> {
3131

32-
def static String getGitVersion(String nextVersion, String snapshotSuffix, File projectDir = null) {
33-
def proc = "git describe --exact-match".execute(null, projectDir);
32+
def static String getGitVersion(String nextVersion, String snapshotSuffix, String gitArgs, File projectDir = null) {
33+
def proc = ("git describe --exact-match " + gitArgs).execute(null, projectDir);
3434
proc.waitFor();
3535
if (proc.exitValue() == 0) {
3636
return checkVersion(proc.text.trim());
3737
}
38-
proc = "git describe".execute(null, projectDir);
38+
proc =("git describe " + gitArgs).execute(null, projectDir);
3939
proc.waitFor();
4040
if (proc.exitValue() == 0) {
4141
def describe = proc.text.trim()
@@ -105,13 +105,17 @@ class SemverGitPlugin implements Plugin<Project> {
105105
void apply(Project project) {
106106
def nextVersion = "minor"
107107
def snapshotSuffix = "SNAPSHOT"
108+
def gitDescribeArgs = '--match *[0-9].[0-9]*.[0-9]*'
108109
if (project.ext.properties.containsKey("nextVersion")) {
109110
nextVersion = project.ext.nextVersion
110111
}
111112
if (project.ext.properties.containsKey("snapshotSuffix")) {
112113
snapshotSuffix = project.ext.snapshotSuffix
113114
}
114-
project.version = getGitVersion(nextVersion, snapshotSuffix, project.projectDir)
115+
if (project.ext.properties.containsKey("gitDescribeArgs")) {
116+
gitDescribeArgs = project.ext.gitDescribeArgs
117+
}
118+
project.version = getGitVersion(nextVersion, snapshotSuffix, gitDescribeArgs, project.projectDir)
115119
project.task('showVersion') {
116120
group = 'Help'
117121
description = 'Show the project version'

0 commit comments

Comments
 (0)