Example usage for org.eclipse.jgit.util RawParseUtils author

List of usage examples for org.eclipse.jgit.util RawParseUtils author

Introduction

In this page you can find the example usage for org.eclipse.jgit.util RawParseUtils author.

Prototype

public static final int author(byte[] b, int ptr) 

Source Link

Document

Locate the "author " header line data.

Usage

From source file:playRepository.GitCommit.java

License:Apache License

/**
 * Parse the author identity from the raw buffer.
 * <p>/*  w ww . j ava2  s.c om*/
 * This method parses and returns the content of the author line, after
 * taking the commit's character set into account and decoding the author
 * name and email address. This method is fairly expensive and produces a
 * new PersonIdent instance on each invocation. Callers should invoke this
 * method only if they are certain they will be outputting the result, and
 * should cache the return value for as long as necessary to use all
 * information from it.
 * <p>
 * RevFilter implementations should try to use {@link RawParseUtils} to scan
 * the {@link RevCommit#getRawBuffer()} instead, as this will allow faster evaluation
 * of commits.
 *
 * @return identity of the author (name, email) and the time the commit was
 *         made by the author; null if no author line was found.
 */
public final PersonIdent getAuthorIdent() {
    if (authorIdent == null) {
        final byte[] raw = revCommit.getRawBuffer();
        final int nameB = RawParseUtils.author(raw, 0);
        if (nameB < 0)
            return null;
        authorIdent = parsePersonIdent(raw, nameB, Charset.defaultCharset());
    }

    return authorIdent;
}