init svn repositories with README.md in trunk folder

This commit is contained in:
Eduard Heimbuch
2020-07-22 14:00:52 +02:00
parent 9a1ec7a5ef
commit b1660f5ec7
8 changed files with 47 additions and 9 deletions

View File

@@ -39,12 +39,13 @@ import sonia.scm.repository.work.WorkingCopy;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class SvnModifyCommand implements ModifyCommand {
private SvnContext context;
private SvnWorkingCopyFactory workingCopyFactory;
private Repository repository;
private final SvnContext context;
private final SvnWorkingCopyFactory workingCopyFactory;
private final Repository repository;
SvnModifyCommand(SvnContext context, SvnWorkingCopyFactory workingCopyFactory) {
this.context = context;
@@ -57,6 +58,9 @@ public class SvnModifyCommand implements ModifyCommand {
SVNClientManager clientManager = SVNClientManager.newInstance();
try (WorkingCopy<File, File> workingCopy = workingCopyFactory.createWorkingCopy(context, null)) {
File workingDirectory = workingCopy.getDirectory();
if (request.isDefaultPath()) {
workingDirectory = Paths.get(workingDirectory.toString() + "/trunk").toFile();
}
modifyWorkingDirectory(request, clientManager, workingDirectory);
return commitChanges(clientManager, workingDirectory, request.getCommitMessage());
}

View File

@@ -101,6 +101,22 @@ public class SvnModifyCommandTest extends AbstractSvnCommandTestBase {
assertThat(new File(workingCopy.getWorkingRepository(), "Test123")).exists();
}
@Test
public void shouldAddNewFileInDefaultPath() throws IOException {
File testfile = temporaryFolder.newFile("Test123");
ModifyCommandRequest request = new ModifyCommandRequest();
request.setDefaultPath(true);
request.addRequest(new ModifyCommandRequest.CreateFileRequest("Test123", testfile, false));
request.setCommitMessage("this is great");
request.setAuthor(new Person("Arthur Dent", "dent@hitchhiker.com"));
svnModifyCommand.execute(request);
WorkingCopy<File, File> workingCopy = workingCopyFactory.createWorkingCopy(context, null);
assertThat(new File(workingCopy.getWorkingRepository(), "trunk/Test123")).exists();
}
@Test
public void shouldThrowFileAlreadyExistsException() throws IOException {
File testfile = temporaryFolder.newFile("a.txt");