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

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

Introduction

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

Prototype

public void setAllowCreates(boolean canCreate) 

Source Link

Document

Whether to permit create 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);
    final boolean mayNonFastForward = subject
            .isPermitted("gitrepo:non-fast-forward:" + getRepoNameAsPermissionParts(repo));
    rp.setAllowDeletes(mayNonFastForward);
    rp.setAllowNonFastForwards(mayNonFastForward);
    rp.setCheckReceivedObjects(true);/* w w w .  ja  va2  s  . c  o  m*/
    // 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);
}