Merge pull request #485 from transamericamoon/svn-label-fix

fix svn repo to also check branches and tags folders for label
This commit is contained in:
Ryan Baxter
2016-08-26 14:24:29 -04:00
committed by GitHub
3 changed files with 36 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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 {

View File

@@ -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();