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

项目: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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoContributorAutoConfiguration.java   
@Bean
@ConditionalOnEnabledInfoContributor("git")
@ConditionalOnSingleCandidate(GitProperties.class)
@ConditionalOnMissingBean
@Order(DEFAULT_ORDER)
public GitInfoContributor gitInfoContributor(GitProperties gitProperties) {
    return new GitInfoContributor(gitProperties, this.properties.getGit().getMode());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:GitInfoContributorTests.java   
@SuppressWarnings("unchecked")
@Test
public void coerceDate() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.time", "2016-03-04T14:36:33+0100");
    GitInfoContributor contributor = new GitInfoContributor(
            new GitProperties(properties));
    Map<String, Object> content = contributor.generateContent();
    assertThat(content.get("commit")).isInstanceOf(Map.class);
    Map<String, Object> commit = (Map<String, Object>) content.get("commit");
    Object commitTime = commit.get("time");
    assertThat(commitTime).isInstanceOf(Date.class);
    assertThat(((Date) commitTime).getTime()).isEqualTo(1457098593000L);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:GitInfoContributorTests.java   
@SuppressWarnings("unchecked")
@Test
public void shortenCommitId() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.id", "8e29a0b0d423d2665c6ee5171947c101a5c15681");
    GitInfoContributor contributor = new GitInfoContributor(
            new GitProperties(properties));
    Map<String, Object> content = contributor.generateContent();
    assertThat(content.get("commit")).isInstanceOf(Map.class);
    Map<String, Object> commit = (Map<String, Object>) content.get("commit");
    assertThat(commit.get("id")).isEqualTo("8e29a0b");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoContributorAutoConfigurationTests.java   
@Bean
public GitProperties gitProperties() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.id", "abcdefg");
    properties.put("foo", "bar");
    return new GitProperties(properties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitPropertiesUnavailableIfResourceNotAvailable() {
    load();
    Map<String, GitProperties> beans = this.context
            .getBeansOfType(GitProperties.class);
    assertThat(beans).hasSize(0);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitLocationTakesPrecedenceOverLegacyKey() {
    load("spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git.properties",
            "spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties.getBranch()).isNull();
    assertThat(gitProperties.getCommitId())
            .isEqualTo("f95038ec09e29d8f91982fd1cbcc0f3b131b1d0a");
    assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1456995720000L);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitLegacyKeyIsUsedAsFallback() {
    load("spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-epoch.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties.getBranch()).isEqualTo("master");
    assertThat(gitProperties.getCommitId())
            .isEqualTo("5009933788f5f8c687719de6a697074ff80b1b69");
    assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1457103850000L);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitPropertiesFallbackWithGitPropertiesBean() {
    load(CustomInfoPropertiesConfiguration.class,
            "spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties).isSameAs(this.context.getBean("customGitProperties"));
}
项目:spring-boot-concourse    文件:InfoContributorAutoConfiguration.java   
@Bean
@ConditionalOnEnabledInfoContributor("git")
@ConditionalOnSingleCandidate(GitProperties.class)
@ConditionalOnMissingBean
@Order(DEFAULT_ORDER)
public GitInfoContributor gitInfoContributor(GitProperties gitProperties) {
    return new GitInfoContributor(gitProperties, this.properties.getGit().getMode());
}
项目:spring-boot-concourse    文件:GitInfoContributorTests.java   
@SuppressWarnings("unchecked")
@Test
public void coerceDate() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.time", "2016-03-04T14:36:33+0100");
    GitInfoContributor contributor = new GitInfoContributor(
            new GitProperties(properties));
    Map<String, Object> content = contributor.generateContent();
    assertThat(content.get("commit")).isInstanceOf(Map.class);
    Map<String, Object> commit = (Map<String, Object>) content.get("commit");
    Object commitTime = commit.get("time");
    assertThat(commitTime).isInstanceOf(Date.class);
    assertThat(((Date) commitTime).getTime()).isEqualTo(1457098593000L);
}
项目:spring-boot-concourse    文件:GitInfoContributorTests.java   
@SuppressWarnings("unchecked")
@Test
public void shortenCommitId() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.id", "8e29a0b0d423d2665c6ee5171947c101a5c15681");
    GitInfoContributor contributor = new GitInfoContributor(
            new GitProperties(properties));
    Map<String, Object> content = contributor.generateContent();
    assertThat(content.get("commit")).isInstanceOf(Map.class);
    Map<String, Object> commit = (Map<String, Object>) content.get("commit");
    assertThat(commit.get("id")).isEqualTo("8e29a0b");
}
项目:spring-boot-concourse    文件:InfoContributorAutoConfigurationTests.java   
@Bean
public GitProperties gitProperties() {
    Properties properties = new Properties();
    properties.put("branch", "master");
    properties.put("commit.id", "abcdefg");
    properties.put("foo", "bar");
    return new GitProperties(properties);
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitPropertiesUnavailableIfResourceNotAvailable() {
    load();
    Map<String, GitProperties> beans = this.context
            .getBeansOfType(GitProperties.class);
    assertThat(beans).hasSize(0);
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitLocationTakesPrecedenceOverLegacyKey() {
    load("spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git.properties",
            "spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties.getBranch()).isNull();
    assertThat(gitProperties.getCommitId())
            .isEqualTo("f95038ec09e29d8f91982fd1cbcc0f3b131b1d0a");
    assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1456995720000L);
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitLegacyKeyIsUsedAsFallback() {
    load("spring.git.properties=classpath:/org/springframework/boot/autoconfigure/info/git-epoch.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties.getBranch()).isEqualTo("master");
    assertThat(gitProperties.getCommitId())
            .isEqualTo("5009933788f5f8c687719de6a697074ff80b1b69");
    assertThat(gitProperties.getCommitTime().getTime()).isEqualTo(1457103850000L);
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitPropertiesFallbackWithGitPropertiesBean() {
    load(CustomInfoPropertiesConfiguration.class,
            "spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties).isSameAs(this.context.getBean("customGitProperties"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:GitInfoContributor.java   
public GitInfoContributor(GitProperties properties, Mode mode) {
    super(properties, mode);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:GitInfoContributor.java   
public GitInfoContributor(GitProperties properties) {
    this(properties, Mode.SIMPLE);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InfoContributorAutoConfigurationTests.java   
@Bean
public GitInfoContributor customGitInfoContributor() {
    return new GitInfoContributor(new GitProperties(new Properties()));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfiguration.java   
@Conditional(GitResourceAvailableCondition.class)
@ConditionalOnMissingBean
@Bean
public GitProperties gitProperties() throws Exception {
    return new GitProperties(loadFrom(this.properties.getGit().getLocation(), "git"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitPropertiesWithNoData() {
    load("spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties.getBranch()).isNull();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ProjectInfoAutoConfigurationTests.java   
@Bean
public GitProperties customGitProperties() {
    return new GitProperties(new Properties());
}
项目:spring-boot-concourse    文件:GitInfoContributor.java   
public GitInfoContributor(GitProperties properties, Mode mode) {
    super(properties, mode);
}
项目:spring-boot-concourse    文件:GitInfoContributor.java   
public GitInfoContributor(GitProperties properties) {
    this(properties, Mode.SIMPLE);
}
项目:spring-boot-concourse    文件:InfoContributorAutoConfigurationTests.java   
@Bean
public GitInfoContributor customGitInfoContributor() {
    return new GitInfoContributor(new GitProperties(new Properties()));
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfiguration.java   
@Conditional(GitResourceAvailableCondition.class)
@ConditionalOnMissingBean
@Bean
public GitProperties gitProperties() throws Exception {
    return new GitProperties(loadFrom(this.properties.getGit().getLocation(), "git"));
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfigurationTests.java   
@Test
public void gitPropertiesWithNoData() {
    load("spring.info.git.location=classpath:/org/springframework/boot/autoconfigure/info/git-no-data.properties");
    GitProperties gitProperties = this.context.getBean(GitProperties.class);
    assertThat(gitProperties.getBranch()).isNull();
}
项目:spring-boot-concourse    文件:ProjectInfoAutoConfigurationTests.java   
@Bean
public GitProperties customGitProperties() {
    return new GitProperties(new Properties());
}
项目:edison-microservice    文件:VersionInfoTest.java   
private GitProperties gitProperties(final String commitId) {
    return new GitProperties(new Properties() {{
        put("commit.id", commitId);
    }});
}
项目: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);
}