Skip to content

Commit

Permalink
Improve git info in build command
Browse files Browse the repository at this point in the history
  • Loading branch information
kantenkugel committed Nov 11, 2018
1 parent d02ca5e commit f87feba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions bot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f87feba

Please sign in to comment.