mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
init svn repositories with README.md in trunk folder
This commit is contained in:
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Changed
|
||||
- Adding start delay to liveness and readiness probes in helm chart template
|
||||
- Init svn repositories with trunk folder ([#1259](https://github.com/scm-manager/scm-manager/pull/1259))
|
||||
|
||||
### Fixed
|
||||
- Fixed file extension detection with new spotter version
|
||||
|
||||
@@ -29,7 +29,8 @@ Icon | Beschreibung
|
||||
### Repository erstellen
|
||||
Im SCM-Manager können neue Git, Mercurial & Subersion (SVN) Repositories über ein Formular angelegt werden. Dieses kann über den Button "Repository erstellen" aufgerufen werden. Dabei muss ein gültiger Name eingetragen und der Repository-Typ bestimmt werden.
|
||||
|
||||
Optional kann man das Repository beim Erstellen direkt initialisieren. Damit werden für Git und Mercurial jeweils der Standard-Branch (master bzw. default) angelegt. Außerdem wird ein initialer Commit ausgeführt, der eine README.md erzeugt.
|
||||
Optional kann man das Repository beim Erstellen direkt initialisieren. Damit werden für Git und Mercurial jeweils der Standard-Branch (master bzw. default) angelegt. Außerdem wird ein initialer Commit ausgeführt, der eine README.md erzeugt.
|
||||
Für Subversion Repositories wird die README.md in einen Ordner `trunk` abgelegt.
|
||||
|
||||
Ist die Namespace-Strategie auf "Benutzerdefiniert" eingestellt, muss noch ein Namespace eingetragen werden.
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ Icon | Description
|
||||
### Create a Repository
|
||||
In SCM-Manager new Git, Mercurial & Subversion (SVN) repositories can be created via a form that can be accessed via the "Create Repository" button. A valid name and the repository type are mandatory.
|
||||
|
||||
Optionally, repositories can be initialized during the creation. That creates a standard branch (master or default) for Git and Mercurial repositories. Additionally, it performs a commit that creates a README.md.
|
||||
Optionally, repositories can be initialized during the creation. That creates a standard branch (master or default) for Git and Mercurial repositories.
|
||||
Additionally, it performs a commit that creates a README.md. For Subversion repositories the README.md will be created in a directory named `trunk`.
|
||||
|
||||
If the namespace strategy is set to custom, the namespace field is also mandatory.
|
||||
|
||||
|
||||
@@ -175,6 +175,11 @@ public class ModifyCommandBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModifyCommandBuilder useDefaultPath(boolean useDefaultPath) {
|
||||
request.setDefaultPath(useDefaultPath);
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface ContentLoader {
|
||||
/**
|
||||
* Specify the data of the file using a {@link ByteSource}.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -48,6 +48,7 @@ public class ModifyCommandRequest implements Resetable, Validateable, CommandWit
|
||||
private String commitMessage;
|
||||
private String branch;
|
||||
private String expectedRevision;
|
||||
private boolean defaultPath;
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
@@ -55,6 +56,7 @@ public class ModifyCommandRequest implements Resetable, Validateable, CommandWit
|
||||
author = null;
|
||||
commitMessage = null;
|
||||
branch = null;
|
||||
defaultPath = false;
|
||||
}
|
||||
|
||||
public void addRequest(PartialRequest request) {
|
||||
@@ -93,6 +95,10 @@ public class ModifyCommandRequest implements Resetable, Validateable, CommandWit
|
||||
return expectedRevision;
|
||||
}
|
||||
|
||||
public boolean isDefaultPath() {
|
||||
return defaultPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return StringUtils.isNotEmpty(commitMessage) && !requests.isEmpty();
|
||||
@@ -102,6 +108,10 @@ public class ModifyCommandRequest implements Resetable, Validateable, CommandWit
|
||||
this.expectedRevision = expectedRevision;
|
||||
}
|
||||
|
||||
public void setDefaultPath(boolean defaultPath) {
|
||||
this.defaultPath = defaultPath;
|
||||
}
|
||||
|
||||
public interface PartialRequest {
|
||||
void execute(ModifyCommand.Worker worker) throws IOException;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RepositoryInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
private class InitializerContextImpl implements RepositoryContentInitializer.InitializerContext {
|
||||
private static class InitializerContextImpl implements RepositoryContentInitializer.InitializerContext {
|
||||
|
||||
private final Repository repository;
|
||||
private final ModifyCommandBuilder builder;
|
||||
@@ -90,11 +90,11 @@ public class RepositoryInitializer {
|
||||
|
||||
@Override
|
||||
public RepositoryContentInitializer.CreateFile create(String path) {
|
||||
return new CreateFileImpl(this, builder.createFile(path).setOverwrite(true));
|
||||
return new CreateFileImpl(this, builder.useDefaultPath(true).createFile(path).setOverwrite(true));
|
||||
}
|
||||
}
|
||||
|
||||
private class CreateFileImpl implements RepositoryContentInitializer.CreateFile {
|
||||
private static class CreateFileImpl implements RepositoryContentInitializer.CreateFile {
|
||||
|
||||
private final RepositoryContentInitializer.InitializerContext initializerContext;
|
||||
private final ModifyCommandBuilder.WithOverwriteFlagContentLoader contentLoader;
|
||||
|
||||
Reference in New Issue
Block a user