Merge with base branch

This commit is contained in:
Rene Pfeuffer
2019-09-04 13:35:40 +02:00
9 changed files with 99 additions and 26 deletions

View File

@@ -124,7 +124,7 @@ public class GitBrowseCommand extends AbstractGitCommand
if (revId != null)
{
result = new BrowserResult(revId.getName(), getEntry(repo, request, revId));
result = new BrowserResult(revId.getName(), request.getRevision(), getEntry(repo, request, revId));
}
else
{
@@ -138,7 +138,7 @@ public class GitBrowseCommand extends AbstractGitCommand
logger.warn("could not find head of repository, empty?");
}
result = new BrowserResult(Constants.HEAD, createEmtpyRoot());
result = new BrowserResult(Constants.HEAD, request.getRevision(), createEmtpyRoot());
}
return result;

View File

@@ -3,6 +3,8 @@ package sonia.scm.repository.spi;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;
import sonia.scm.BadRequestException;
import sonia.scm.ConcurrentModificationException;
@@ -23,6 +25,7 @@ import java.util.Optional;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static sonia.scm.AlreadyExistsException.alreadyExists;
import static sonia.scm.ContextEntry.ContextBuilder.entity;
import static sonia.scm.ScmConstraintViolationException.Builder.doThrow;
public class GitModifyCommand extends AbstractGitCommand implements ModifyCommand {
@@ -54,6 +57,9 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
if (!StringUtils.isEmpty(request.getBranch())) {
checkOutBranch(request.getBranch());
}
Ref head = getClone().getRepository().exactRef(Constants.HEAD);
doThrow().violation("branch has to be a valid branch, no revision", "branch", request.getBranch()).when(head == null || !head.isSymbolic());
getClone().getRepository().getFullBranch();
if (!StringUtils.isEmpty(request.getExpectedRevision())) {
if (!request.getExpectedRevision().equals(getCurrentRevision().getName())) {
throw new ConcurrentModificationException("branch", request.getBranch() == null? "default": request.getBranch());