Example usage for org.eclipse.jgit.api NameRevCommand addPrefix

List of usage examples for org.eclipse.jgit.api NameRevCommand addPrefix

Introduction

In this page you can find the example usage for org.eclipse.jgit.api NameRevCommand addPrefix.

Prototype

public NameRevCommand addPrefix(String prefix) 

Source Link

Document

Add a ref prefix to the set that results must match.

Usage

From source file:com.google.gitiles.DescribeServlet.java

License:Open Source License

private NameRevCommand nameRevCommand(ObjectId id, HttpServletRequest req, HttpServletResponse res)
        throws IOException {
    Repository repo = ServletUtils.getRepository(req);
    GitilesView view = ViewFilter.getView(req);
    NameRevCommand cmd = new Git(repo).nameRev();
    boolean all = getBooleanParam(view, ALL_PARAM);
    boolean tags = getBooleanParam(view, TAGS_PARAM);
    if (all && tags) {
        renderTextError(req, res, SC_BAD_REQUEST, "Cannot specify both \"all\" and \"tags\"");
        return null;
    }// w  w  w.  j  a v  a2 s.  c om
    if (all) {
        cmd.addPrefix(Constants.R_REFS);
    } else if (tags) {
        cmd.addPrefix(Constants.R_TAGS);
    } else {
        cmd.addAnnotatedTags();
    }
    cmd.add(id);
    return cmd;
}