From f87febaa12f33870f178d453f61b56481a004c36 Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Sat, 10 Nov 2018 19:42:16 +0100 Subject: [PATCH] Improve git info in build command --- bot/build.gradle | 6 +++--- .../com/almightyalpaca/discord/jdabutler/BotVersion.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/build.gradle b/bot/build.gradle index 8dc79324..975d4fab 100644 --- a/bot/build.gradle +++ b/bot/build.gradle @@ -52,10 +52,10 @@ dependencies { } task getBotVersionInfo(type: Exec) { + commandLine 'git', 'log', '-1', '--format=[%ci]%n%H%n%s' + if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) { - commandLine 'cmd', '/c', 'git', 'log', '-1', '--format=%D%n[%ci] %H%n%s' //don't use trailing ", it will get printed for some reason - } else { - commandLine 'git', 'log', '-1', '--format="%D%n[%ci] %H%n%s' + commandLine = ['cmd', '/c'] + commandLine //don't use trailing ", it will get printed for some reason } //store the output instead of printing to the console: diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/BotVersion.java b/src/main/java/com/almightyalpaca/discord/jdabutler/BotVersion.java index 64268554..a5e8c290 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/BotVersion.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/BotVersion.java @@ -7,8 +7,8 @@ public class BotVersion private static final String[] GIT_LINES = GIT_INFO.split("\n"); - public static final String GIT_REF = GIT_LINES.length == 1 ? "" : GIT_LINES[0]; - public static final String GIT_COMMIT = GIT_LINES.length == 1 ? "" : GIT_LINES[1]; + public static final String GIT_DATE = GIT_LINES.length == 1 ? "" : GIT_LINES[0]; + public static final String GIT_HASH = GIT_LINES.length == 1 ? "" : GIT_LINES[1]; public static final String GIT_MSG = GIT_LINES.length == 1 ? "" : GIT_LINES[2]; public static final String FULL_VERSION = String.format("Build: %s\n\nGit:\n%s", BUILD, GIT_INFO);