protected Optional<? extends Ref> _call() { checkState(branchName != null, "Branch name not provided"); Optional<Ref> branchRef = command(RefParse.class).setName(branchName).call(); if (branchRef.isPresent()) { final Ref ref = branchRef.get(); checkState(!(ref instanceof SymRef)); final Optional<Ref> head = command(RefParse.class).setName(Ref.HEAD).call(); checkArgument( !(head.isPresent() && head.get() instanceof SymRef "Cannot delete the branch you are on"); UpdateRef updateRef = command(UpdateRef.class).setName(ref.getName()).setDelete(true) .setReason("Delete branch " + ref.getName()); branchRef = updateRef.call();
protected Optional<? extends Ref> _call() { checkState(branchName != null, "Branch name not provided"); Optional<Ref> branchRef = command(RefParse.class).setName(branchName).call(); if (branchRef.isPresent()) { final Ref ref = branchRef.get(); checkState(!(ref instanceof SymRef)); final Optional<Ref> head = command(RefParse.class).setName(Ref.HEAD).call(); checkArgument( !(head.isPresent() && head.get() instanceof SymRef config = command(BranchConfigOp.class).setName(ref.getName()).delete(); } catch (RuntimeException ignore) { config = null; UpdateRef updateRef = command(UpdateRef.class).setName(ref.getName()).setDelete(true) .setReason("Delete branch " + ref.getName()); branchRef = updateRef.call();