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

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

Introduction

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

Prototype

public void setCheckReceivedObjects(boolean check) 

Source Link

Document

Whether to enable checking received objects

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 w  w  w .j av  a  2 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);
}