diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/SvnKitEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/SvnKitEnvironmentRepository.java index a20114fd..41d66dd0 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/SvnKitEnvironmentRepository.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/SvnKitEnvironmentRepository.java @@ -179,7 +179,18 @@ public class SvnKitEnvironmentRepository extends AbstractScmEnvironmentRepositor private File getSvnPath(File workingDirectory, String label) { // use label as path relative to repository root - return new File(workingDirectory, label); + // if it doesn't exists check branches and then tags folders + File svnPath = new File(workingDirectory, label); + if(!svnPath.exists()) { + svnPath = new File(workingDirectory, "branches" + File.separator + label); + if(!svnPath.exists()) { + svnPath = new File(workingDirectory, "tags" + File.separator + label); + if(!svnPath.exists()) { + throw new NoSuchLabelException("No label found for: " + label); + } + } + } + return svnPath; } } diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryIntegrationTests.java index 471f1da1..44807ce4 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryIntegrationTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryIntegrationTests.java @@ -17,6 +17,7 @@ package org.springframework.cloud.config.server.environment; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileNotFoundException; @@ -143,6 +144,20 @@ public class SVNKitEnvironmentRepositoryIntegrationTests { assertEquals(0, environment.getPropertySources().size()); } + @Test + public void branchLabel() throws Exception { + String uri = ConfigServerTestUtils.prepareLocalSvnRepo( + "src/test/resources/svn-config-repo", "target/config"); + this.context = new SpringApplicationBuilder(TestConfiguration.class).web(false) + .profiles("subversion") + .run("--spring.cloud.config.server.svn.uri=" + uri); + EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class); + Environment environment = repository.findOne("bar", "staging", "demobranch"); + assertTrue(environment.getPropertySources().get(0).getName() + .contains("bar.properties")); + assertEquals(1, environment.getPropertySources().size()); + } + @Configuration @Import({ PropertyPlaceholderAutoConfiguration.class, EnvironmentRepositoryConfiguration.class }) protected static class TestConfiguration { diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryTests.java index 81b59ec4..9bda8832 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/SVNKitEnvironmentRepositoryTests.java @@ -103,6 +103,15 @@ public class SVNKitEnvironmentRepositoryTests { .contains("bar.properties")); } + @Test + public void branch_no_folder() { + Environment environment = this.repository.findOne("bar", "staging", + "demobranch"); + assertEquals(1, environment.getPropertySources().size()); + assertTrue(environment.getPropertySources().get(0).getName() + .contains("bar.properties")); + } + @Test public void vanilla_with_update() { this.findOne();