Skip to content

Commit

Permalink
use project dir in getGitVersion
Browse files Browse the repository at this point in the history
rather than running `git describe` in the current working dir, run it in
the directory of the gradle project. This allows projects that come from
git submodules to use the versions from their tags.
  • Loading branch information
zombiedev committed Feb 10, 2016
1 parent abb0bd6 commit 98f7bb6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import org.gradle.api.Plugin

class SemverGitPlugin implements Plugin<Project> {

def static String getGitVersion(String nextVersion, String snapshotSuffix) {
def proc = "git describe --exact-match".execute();
def static String getGitVersion(String nextVersion, String snapshotSuffix, File projectDir = null) {
def proc = "git describe --exact-match".execute(null, projectDir);
proc.waitFor();
if (proc.exitValue() == 0) {
return checkVersion(proc.text.trim());
}
proc = "git describe".execute();
proc = "git describe".execute(null, projectDir);
proc.waitFor();
if (proc.exitValue() == 0) {
def describe = proc.text.trim()
Expand Down Expand Up @@ -111,7 +111,7 @@ class SemverGitPlugin implements Plugin<Project> {
if (project.ext.properties.containsKey("snapshotSuffix")) {
snapshotSuffix = project.ext.snapshotSuffix
}
project.version = getGitVersion(nextVersion, snapshotSuffix)
project.version = getGitVersion(nextVersion, snapshotSuffix, project.projectDir)
project.task('showVersion') {
group = 'Help'
description = 'Show the project version'
Expand Down

0 comments on commit 98f7bb6

Please sign in to comment.