package cn.home1.oss.environment.configserver;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.config.server.config.ConfigServerHealthIndicator;
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;

@Configuration
@ConditionalOnProperty(prefix = "spring.cloud.config.server.commonConfig", name = "enabled", havingValue = "true")
public class CommonConfigConfiguration {


  @Bean
  @ConditionalOnProperty(value = "spring.cloud.config.server.health.enabled", matchIfMissing = true)
  public ConfigServerHealthIndicator configServerHealthIndicator(EnvironmentRepository repository) {
    return new ConfigServerHealthIndicator(repository);
  }


  @Configuration
  @ConditionalOnMissingBean(EnvironmentRepository.class)
  public static class OssGitRepositoryConfiguration {

    @Autowired
    private ConfigurableEnvironment environment;

    @Bean
    @ConditionalOnMissingBean(EnvironmentRepository.class)
    public EnvironmentRepository environmentRepository() {

      final CommonConfigSupportedMultipleJGitEnvironmentRepository repository =
          new CommonConfigSupportedMultipleJGitEnvironmentRepository(this.environment);

      return repository;
    }
  }
}

@@ -104,16 +104,75 @@
 owired;%0A
+import org.springframework.beans.factory.annotation.Value;%0A
 import o
@@ -1301,16 +1301,110 @@
 ronment;
+%0A    %0A    @Value(%22$%7Bspring.cloud.config.server.jgit.timeout:10%7D%22)%0A    private Integer timeout;
 %0A%0A    @B
@@ -1693,16 +1693,100 @@
 onment);
+%0A      %0A      if (timeout != null) %7B%0A        repository.setTimeout(timeout);%0A      %7D
 %0A%0A      

fix #5, because of timeout