com.databasesandlife.util.GitPropertiesBuildInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common Show documentation
Show all versions of java-common Show documentation
Utility classes developed at Adrian Smith Software (A.S.S.)
package com.databasesandlife.util;
import javax.annotation.Nonnull;
import java.util.ResourceBundle;
/**
* Reads from "git.properties" as produced by git-commit-id-plugin v2.2.4.
* Use useNativeGit always otherwise dirty property is always set to true.
*/
public class GitPropertiesBuildInfo {
protected static final GitPropertiesBuildInfo instance = new GitPropertiesBuildInfo();
private GitPropertiesBuildInfo() { }
public static @Nonnull GitPropertiesBuildInfo get() { return instance; }
protected @Nonnull ResourceBundle getResourceBundle() {
return ResourceBundle.getBundle("git");
}
/** @return "123abcde-dirty" */
public String getGitRevision() {
var dirty = Boolean.parseBoolean(getResourceBundle().getString("git.dirty"));
var hash = getResourceBundle().getString("git.commit.id.abbrev");
return hash + (dirty ? "-dirty" : "");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy