类org.springframework.boot.info.GitProperties源码实例Demo

下面列出了怎么用org.springframework.boot.info.GitProperties的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jhipster   文件: PrefixedKeyGenerator.java
private String generatePrefix(GitProperties gitProperties, BuildProperties buildProperties) {

        String shortCommitId = null;
        if (Objects.nonNull(gitProperties)) {
            shortCommitId = gitProperties.getShortCommitId();
        }

        Instant time = null;
        String version = null;
        if (Objects.nonNull(buildProperties)) {
            time = buildProperties.getTime();
            version = buildProperties.getVersion();
        }
        Object p = ObjectUtils.firstNonNull(shortCommitId, time, version, RandomStringUtils.randomAlphanumeric(12));

        if (p instanceof Instant) {
            return DateTimeFormatter.ISO_INSTANT.format((Instant) p);
        }
        return p.toString();
    }
 
源代码2 项目: edison-microservice   文件: VersionInfo.java
private VersionInfo(final VersionInfoProperties versionInfoProperties, final GitProperties gitProperties) {
    if (gitProperties != null) {
        this.commitId = gitProperties.getCommitId();
        this.commitIdAbbrev = gitProperties.getShortCommitId();
        this.branch = gitProperties.getBranch();
        this.commitTime = gitProperties.get(COMMIT_TIME);
        this.userName = gitProperties.get(USER_NAME);
        this.userEmail = gitProperties.get(USER_EMAIL);
        this.messageShort = gitProperties.get(MESSAGE_SHORT);
        this.messageFull = gitProperties.get(MESSAGE_FULL);

    } else {
        this.commitId = versionInfoProperties.getCommitId();
        this.commitIdAbbrev= versionInfoProperties.getCommitIdAbbrev();
        this.commitTime = versionInfoProperties.getCommitTime();
        this.userName = versionInfoProperties.getUserName();
        this.userEmail = versionInfoProperties.getUserEmail();
        this.messageShort = versionInfoProperties.getMessageShort();
        this.messageFull = versionInfoProperties.getMessageFull();
        this.branch = versionInfoProperties.getBranch();
    }
    this.version = Objects.toString(versionInfoProperties.getVersion(), this.commitId);
    this.url = versionInfoProperties.getUrlTemplate().replace("{commit}", commitId).replace("{version}", version);
}
 
源代码3 项目: fredbet   文件: SystemInfoService.java
private void addStaticProperties() {
    add("Build Time", buildProperties.getTime());
    add("Build Version", buildProperties.getVersion());
    add("Java Version", buildProperties.get("java.source"));

    if (gitProperties.isPresent()) {
        GitProperties gitProps = gitProperties.get();
        add("Commit ID", gitProps.getCommitId());
        add("Branch", gitProps.getBranch());
        add("Commit Message", gitProps.get("commit.message.full"));
        add("Commit Time", gitProps.getCommitTime());
    }

    addSpringProfiles();
    addEnvProperty("JDBC Driver Class","spring.datasource.hikari.driver-class-name");
    addEnvProperty("JDBC-URL","spring.datasource.hikari.jdbc-url");
    addEnvProperty("Image Location","fredbet.image-location");
    addEnvProperty("Image Size","fredbet.image-size");
    addEnvProperty("Thumbnail Size","fredbet.thumbnail-size");
    addEnvProperty("AWS S3 Bucket Name","fredbet.aws-s3bucket-name");
    addEnvProperty("AWS Region","fredbet.aws-region");
}
 
public GitProperties getGit() {
    Properties e = entries.entrySet()
            .stream()
            .filter(entry -> entry.toString().startsWith("git"))
            .collect(Collectors.toMap(
                    entry -> entry.getKey().toString().replace("git", ""),
                    Map.Entry::getValue, (v1, v2) -> {
                        throw new RuntimeException();
                    },
                    Properties::new));
    return new GitProperties(e);
}
 
源代码5 项目: fredbet   文件: SystemInfoService.java
@Autowired
public SystemInfoService(BuildProperties buildProperties, Environment environment, Optional<GitProperties> gitProperties) {
    this.buildProperties = buildProperties;
    this.environment = environment;
    this.gitProperties = gitProperties;
    addStaticProperties();
}
 
源代码6 项目: edison-microservice   文件: VersionInfoTest.java
private GitProperties gitProperties(final String commitId) {
    return new GitProperties(new Properties() {{
        put("commit.id", commitId);
    }});
}
 
源代码7 项目: jhipster   文件: PrefixedKeyGeneratorTest.java
@Test
public void generatePrefixFromShortCommitId() {

    Properties gitProperties = new Properties();
    gitProperties.put("commit.id.abbrev", "1234");

    PrefixedKeyGenerator prefixedKeyGenerator = new PrefixedKeyGenerator(new GitProperties(gitProperties), null);

    assertThat(prefixedKeyGenerator.getPrefix()).isEqualTo("1234");
}
 
源代码8 项目: jhipster   文件: PrefixedKeyGeneratorTest.java
@Test
public void generatePrefixFromCommitId() {

    Properties gitProperties = new Properties();
    gitProperties.put("commit.id", "1234567");

    PrefixedKeyGenerator prefixedKeyGenerator = new PrefixedKeyGenerator(new GitProperties(gitProperties), null);

    assertThat(prefixedKeyGenerator.getPrefix()).isEqualTo("1234567");
}
 
源代码9 项目: jhipster   文件: PrefixedKeyGenerator.java
public PrefixedKeyGenerator(GitProperties gitProperties, BuildProperties buildProperties) {

        this.prefix = generatePrefix(gitProperties, buildProperties);
    }
 
源代码10 项目: edison-microservice   文件: VersionInfo.java
/**
 * Creates VersionInfo from Spring Boot {@link GitProperties}. Missing Information ({@link #version} and
 * {@link #url})is filled from VersionInfoProperties.
 *
 * @param versionInfoProperties Edison VersionInfoProperties used for version and url
 * @param gitProperties Spring Boot GitProperties for all the other properties.
 * @return VersionInfo
 */
public static VersionInfo versionInfo(final VersionInfoProperties versionInfoProperties,
                                      final GitProperties gitProperties) {
    return new VersionInfo(versionInfoProperties, gitProperties);
}
 
 类所在包
 类方法
 同包方法