From 1571a1ce69e73948a06fa4a4610f96c1eba417f4 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Fri, 16 Dec 2016 23:57:17 +0100 Subject: Add git hash instead of timestamp to package version --- build.gradle | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d35d0bb..8087483 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,15 @@ ext { sshReindexCommand = 'cd public_html/public/debian && make' } +final getGitHash = { File file -> + final hashStdOut = new ByteArrayOutputStream() + exec { + commandLine "git", "log", "-n", "1", "--format=format:%h", file.path + standardOutput = hashStdOut + } + return hashStdOut.toString().trim() +} + allprojects { configurations { sshAntTask @@ -111,7 +120,7 @@ subprojects { project.afterEvaluate { ospackage.version = project.version - ospackage.release = "${new Date().format("yyyyMMdd")}T${new Date().format("HHmmss")}" + ospackage.release = "${getGitHash(project.projectDir)}" } final activatorExtension = [ @@ -152,3 +161,4 @@ subprojects { tasks.getByName('buildDeb').dependsOn(activatorTask) tasks.getByName('buildRpm').dependsOn(activatorTask) } + -- cgit v1.2.1