mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Remove leading slashes when changing files in git
This commit is contained in:
@@ -97,6 +97,24 @@ public class GitModifyCommandTest extends AbstractGitCommandTestBase {
|
||||
assertInTree(assertions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateNewFileWhenPathStartsWithSlash() throws IOException, GitAPIException {
|
||||
File newFile = Files.write(temporaryFolder.newFile().toPath(), "new content".getBytes()).toFile();
|
||||
|
||||
GitModifyCommand command = createCommand();
|
||||
|
||||
ModifyCommandRequest request = new ModifyCommandRequest();
|
||||
request.setCommitMessage("test commit");
|
||||
request.addRequest(new ModifyCommandRequest.CreateFileRequest("/new_file", newFile, false));
|
||||
request.setAuthor(new Person("Dirk Gently", "dirk@holistic.det"));
|
||||
|
||||
command.execute(request);
|
||||
|
||||
TreeAssertions assertions = canonicalTreeParser -> assertThat(canonicalTreeParser.findFile("new_file")).isTrue();
|
||||
|
||||
assertInTree(assertions);
|
||||
}
|
||||
|
||||
@Test(expected = AlreadyExistsException.class)
|
||||
public void shouldFailIfOverwritingExistingFileWithoutOverwriteFlag() throws IOException {
|
||||
File newFile = Files.write(temporaryFolder.newFile().toPath(), "new content".getBytes()).toFile();
|
||||
|
||||
Reference in New Issue
Block a user