Example usage for org.eclipse.jgit.lib ReflogEntry getWho

List of usage examples for org.eclipse.jgit.lib ReflogEntry getWho

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib ReflogEntry getWho.

Prototype

PersonIdent getWho();

Source Link

Document

Get user performing the change

Usage

From source file:com.google.gerrit.server.project.GetReflog.java

License:Apache License

@Override
public List<ReflogEntryInfo> apply(BranchResource rsrc)
        throws AuthException, ResourceNotFoundException, RepositoryNotFoundException, IOException {
    if (!rsrc.getControl().isOwner()) {
        throw new AuthException("not project owner");
    }//from w w w  .  jav a 2  s .c om

    try (Repository repo = repoManager.openRepository(rsrc.getNameKey())) {
        ReflogReader r = repo.getReflogReader(rsrc.getRef());
        if (r == null) {
            throw new ResourceNotFoundException(rsrc.getRef());
        }
        List<ReflogEntry> entries;
        if (from == null && to == null) {
            entries = limit > 0 ? r.getReverseEntries(limit) : r.getReverseEntries();
        } else {
            entries = limit > 0 ? new ArrayList<ReflogEntry>(limit) : new ArrayList<ReflogEntry>();
            for (ReflogEntry e : r.getReverseEntries()) {
                Timestamp timestamp = new Timestamp(e.getWho().getWhen().getTime());
                if ((from == null || from.before(timestamp)) && (to == null || to.after(timestamp))) {
                    entries.add(e);
                }
                if (limit > 0 && entries.size() >= limit) {
                    break;
                }
            }
        }
        return Lists.transform(entries, new Function<ReflogEntry, ReflogEntryInfo>() {
            @Override
            public ReflogEntryInfo apply(ReflogEntry e) {
                return new ReflogEntryInfo(e);
            }
        });
    }
}