diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBranchCommand.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBranchCommand.java index 787cfb78bf..208b534343 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBranchCommand.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBranchCommand.java @@ -69,14 +69,21 @@ public class GitBranchCommand extends AbstractGitCommand implements BranchComman .flatMap(pushResult -> pushResult.getRemoteUpdates().stream()) .filter(remoteRefUpdate -> remoteRefUpdate.getStatus() != RemoteRefUpdate.Status.OK) .findFirst() - .ifPresent(this::handlePushError); + .ifPresent(r -> this.handlePushError(r, request, context.getRepository())); return Branch.normalBranch(request.getNewBranch(), GitUtil.getId(ref.getObjectId())); } catch (GitAPIException ex) { throw new InternalRepositoryException(repository, "could not create branch " + request.getNewBranch(), ex); } } - private void handlePushError(RemoteRefUpdate remoteRefUpdate) { - // TODO handle failed remote update + private void handlePushError(RemoteRefUpdate remoteRefUpdate, BranchRequest request, Repository repository) { + if (remoteRefUpdate.getStatus() != RemoteRefUpdate.Status.OK) { + // TODO handle failed remote update + throw new RuntimeException( + String.format("Could not pull new branch '%s' into central repository '%s': %s", + request.getNewBranch(), + repository.getNamespaceAndName(), + remoteRefUpdate.getMessage())); + } } } diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/HgBranchCommand.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/HgBranchCommand.java index 24fb88ce50..5a0b6d0cd1 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/HgBranchCommand.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/HgBranchCommand.java @@ -81,7 +81,12 @@ public class HgBranchCommand extends AbstractCommand implements BranchCommand { workdirFactory.configure(pullCommand); pullCommand.execute(workingCopy.getDirectory().getAbsolutePath()); } catch (Exception e) { - throw new RuntimeException(e); + // TODO handle failed update + throw new RuntimeException( + String.format("Could not pull new branch '%s' into central repository '%s'", + request.getNewBranch(), + getRepository().getNamespaceAndName()), + e); } return Branch.normalBranch(request.getNewBranch(), emptyChangeset.getNode());