mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-01 13:19:53 +01:00
Add parameter to check current revision to prevent conflicts
This commit is contained in:
@@ -240,6 +240,10 @@ class AbstractGitCommand
|
||||
logger.debug("pushed changes");
|
||||
}
|
||||
|
||||
Ref getCurrentRevision() throws IOException {
|
||||
return getClone().getRepository().getRefDatabase().findRef("HEAD");
|
||||
}
|
||||
|
||||
private Person determineAuthor(Person author) {
|
||||
if (author == null) {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import sonia.scm.BadRequestException;
|
||||
import sonia.scm.ConcurrentModificationException;
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.repository.GitWorkdirFactory;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
@@ -51,6 +52,11 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
|
||||
if (!StringUtils.isEmpty(request.getBranch())) {
|
||||
checkOutBranch(request.getBranch());
|
||||
}
|
||||
if (!StringUtils.isEmpty(request.getExpectedRevision())) {
|
||||
if (!request.getExpectedRevision().equals(getCurrentRevision().getName())) {
|
||||
throw new ConcurrentModificationException("branch", request.getBranch() == null? "default": request.getBranch());
|
||||
}
|
||||
}
|
||||
for (ModifyCommandRequest.PartialRequest r : request.getRequests()) {
|
||||
r.execute(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user