All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.databasesandlife.util.GitPropertiesBuildInfo Maven / Gradle / Ivy

There is a newer version: 21.0.1
Show newest version
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