Example usage for org.eclipse.jgit.transport ReceivePack setAllowDeletes

List of usage examples for org.eclipse.jgit.transport ReceivePack setAllowDeletes

Introduction

In this page you can find the example usage for org.eclipse.jgit.transport ReceivePack setAllowDeletes.

Prototype

public void setAllowDeletes(boolean canDelete) 

Source Link

Document

Whether to permit delete ref commands to be processed.

Usage

From source file:com.sonatype.sshjgit.core.gitcommand.Receive.java

License:Apache License

@Override
protected void runImpl() throws IOException, Failure {
    final Subject subject = SecurityUtils.getSubject();
    subject.checkPermission("gitrepo:push:" + getRepoNameAsPermissionParts(repo));
    ReceivePack rp = new ReceivePack(repo);
    rp.setAllowCreates(true);/*from  ww w.  j a  va2  s.  co m*/
    final boolean mayNonFastForward = subject
            .isPermitted("gitrepo:non-fast-forward:" + getRepoNameAsPermissionParts(repo));
    rp.setAllowDeletes(mayNonFastForward);
    rp.setAllowNonFastForwards(mayNonFastForward);
    rp.setCheckReceivedObjects(true);
    // TODO make this be a real email address!
    final String name;
    final Object principal = subject.getPrincipal();
    if (principal == null) {
        name = "null_principal";
        log.warn("principal was null when trying to setRefLogIdent on repo.");
    } else {
        name = principal.toString();
    }
    log.info("setting LogIdent to " + name);
    rp.setRefLogIdent(new PersonIdent(name, name + "@example.com"));
    rp.receive(in, out, err);
}