Example usage for org.eclipse.jgit.revwalk RevSort NONE

List of usage examples for org.eclipse.jgit.revwalk RevSort NONE

Introduction

In this page you can find the example usage for org.eclipse.jgit.revwalk RevSort NONE.

Prototype

RevSort NONE

To view the source code for org.eclipse.jgit.revwalk RevSort NONE.

Click Source Link

Document

No specific sorting is requested.

Usage

From source file:com.google.gerrit.server.git.ReceiveCommits.java

License:Apache License

private void validateNewCommits(RefControl ctl, ReceiveCommand cmd) {
    if (ctl.canForgeAuthor() && ctl.canForgeCommitter() && ctl.canForgeGerritServerIdentity()
            && ctl.canUploadMerges() && !projectControl.getProjectState().isUseSignedOffBy()
            && Iterables.isEmpty(rejectCommits) && !RefNames.REFS_CONFIG.equals(ctl.getRefName())
            && !(MagicBranch.isMagicBranch(cmd.getRefName())
                    || NEW_PATCHSET.matcher(cmd.getRefName()).matches())) {
        return;//from w  w  w . j  a  va  2s.c o  m
    }

    boolean defaultName = Strings.isNullOrEmpty(currentUser.getAccount().getFullName());
    final RevWalk walk = rp.getRevWalk();
    walk.reset();
    walk.sort(RevSort.NONE);
    try {
        RevObject parsedObject = walk.parseAny(cmd.getNewId());
        if (!(parsedObject instanceof RevCommit)) {
            return;
        }
        walk.markStart((RevCommit) parsedObject);
        markHeadsAsUninteresting(walk, cmd.getRefName());
        Set<ObjectId> existing = changeRefsById().keySet();
        for (RevCommit c; (c = walk.next()) != null;) {
            if (existing.contains(c)) {
                continue;
            } else if (!validCommit(ctl, cmd, c)) {
                break;
            }

            if (defaultName && currentUser.hasEmailAddress(c.getCommitterIdent().getEmailAddress())) {
                try {
                    Account a = db.accounts().get(currentUser.getAccountId());
                    if (a != null && Strings.isNullOrEmpty(a.getFullName())) {
                        a.setFullName(c.getCommitterIdent().getName());
                        db.accounts().update(Collections.singleton(a));
                        currentUser.getAccount().setFullName(a.getFullName());
                        accountCache.evict(a.getId());
                    }
                } catch (OrmException e) {
                    log.warn("Cannot default full_name", e);
                } finally {
                    defaultName = false;
                }
            }
        }
    } catch (IOException err) {
        cmd.setResult(REJECTED_MISSING_OBJECT);
        log.error("Invalid pack upload; one or more objects weren't sent", err);
    }
}