remove unnecessary handler from HgModifyCommand / move NoChangesMadeException to scm-core

This commit is contained in:
Eduard Heimbuch
2019-10-02 10:43:35 +02:00
parent 75346c925e
commit 6417ab57e8
5 changed files with 33 additions and 27 deletions

View File

@@ -6,9 +6,9 @@ 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;
import sonia.scm.ContextEntry;
import sonia.scm.NoChangesMadeException;
import sonia.scm.repository.GitWorkdirFactory;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
@@ -68,10 +68,10 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
for (ModifyCommandRequest.PartialRequest r : request.getRequests()) {
r.execute(this);
}
failIfNotChanged(NoChangesMadeException::new);
failIfNotChanged(() -> new NoChangesMadeException(repository, ModifyWorker.this.request.getBranch()));
Optional<RevCommit> revCommit = doCommit(request.getCommitMessage(), request.getAuthor());
push();
return revCommit.orElseThrow(NoChangesMadeException::new).name();
return revCommit.orElseThrow(() -> new NoChangesMadeException(repository, ModifyWorker.this.request.getBranch())).name();
}
@Override
@@ -156,17 +156,6 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
public void move(String sourcePath, String targetPath) {
}
private class NoChangesMadeException extends BadRequestException {
public NoChangesMadeException() {
super(ContextEntry.ContextBuilder.entity(context.getRepository()).build(), "no changes detected to branch " + ModifyWorker.this.request.getBranch());
}
@Override
public String getCode() {
return "40RaYIeeR1";
}
}
}
private String throwInternalRepositoryException(String message, Exception e) {