Verify that branch is a branch

This commit is contained in:
Rene Pfeuffer
2019-09-04 13:24:59 +02:00
parent 80b48b1dc4
commit 5f037762c7
2 changed files with 23 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import org.junit.rules.TemporaryFolder;
import sonia.scm.AlreadyExistsException;
import sonia.scm.BadRequestException;
import sonia.scm.ConcurrentModificationException;
import sonia.scm.ScmConstraintViolationException;
import sonia.scm.repository.Person;
import sonia.scm.repository.util.WorkdirProvider;
@@ -156,6 +157,21 @@ public class GitModifyCommandTest extends AbstractGitCommandTestBase {
command.execute(request);
}
@Test(expected = ScmConstraintViolationException.class)
public void shouldFailWithConstraintViolationIfBranchIsNoBranch() throws IOException {
File newFile = Files.write(temporaryFolder.newFile().toPath(), "irrelevant\n".getBytes()).toFile();
GitModifyCommand command = createCommand();
ModifyCommandRequest request = new ModifyCommandRequest();
request.setCommitMessage("test commit");
request.setBranch("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4");
request.addRequest(new ModifyCommandRequest.CreateFileRequest("irrelevant", newFile, true));
request.setAuthor(new Person("Dirk Gently", "dirk@holistic.det"));
command.execute(request);
}
private void assertInTree(TreeAssertions assertions) throws IOException, GitAPIException {
try (Git git = new Git(createContext().open())) {
RevCommit lastCommit = getLastCommit(git);