Example usage for org.eclipse.jgit.lib RefDatabase getRef

List of usage examples for org.eclipse.jgit.lib RefDatabase getRef

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib RefDatabase getRef.

Prototype

@Deprecated
@Nullable
public final Ref getRef(String name) throws IOException 

Source Link

Document

Compatibility synonym for #findRef(String) .

Usage

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

License:Open Source License

static List<Map<String, Object>> getBranchesSoyData(HttpServletRequest req, int limit) throws IOException {
    RefDatabase refdb = ServletUtils.getRepository(req).getRefDatabase();
    Ref head = refdb.getRef(Constants.HEAD);
    Ref headLeaf = head != null && head.isSymbolic() ? head.getLeaf() : null;
    return getRefsSoyData(refdb, ViewFilter.getView(req), Constants.R_HEADS, branchComparator(headLeaf),
            headLeaf, limit);/*from   w  ww . j a  va2 s.com*/
}

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

License:Open Source License

private static List<Map<String, Object>> getRefsSoyData(RefDatabase refdb, GitilesView view, String prefix,
        Ordering<Ref> ordering, @Nullable Ref headLeaf, int limit) throws IOException {
    Collection<Ref> refs = refdb.getRefs(prefix).values();
    refs = ordering.leastOf(refs, limit > 0 ? Ints.saturatedCast(limit + 1L) : refs.size());
    List<Map<String, Object>> result = Lists.newArrayListWithCapacity(refs.size());

    for (Ref ref : refs) {
        String name = ref.getName().substring(prefix.length());
        boolean needPrefix = !ref.getName().equals(refdb.getRef(name).getName());
        Map<String, Object> value = Maps.newHashMapWithExpectedSize(3);
        value.put("url", GitilesView.revision().copyFrom(view)
                .setRevision(Revision.unpeeled(needPrefix ? ref.getName() : name, ref.getObjectId())).toUrl());
        value.put("name", name);
        if (headLeaf != null) {
            value.put("isHead", headLeaf.equals(ref));
        }/*from   ww w  . j ava  2  s.c  om*/
        result.add(value);
    }
    return result;
}

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

License:Open Source License

private static Map<String, Ref> getRefs(RefDatabase refdb, String path) throws IOException {
    path = GitilesView.maybeTrimLeadingAndTrailingSlash(path);
    if (path.isEmpty()) {
        return refdb.getRefs(RefDatabase.ALL);
    }//w  ww  .j  av a  2s  . c  om
    path = Constants.R_REFS + path;
    Ref singleRef = refdb.getRef(path);
    if (singleRef != null) {
        return ImmutableMap.of(singleRef.getName(), singleRef);
    }
    return refdb.getRefs(path + '/');
}

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

License:Open Source License

private List<Map<String, String>> getRefs(HttpServletRequest req, String prefix) throws IOException {
    RefDatabase refdb = ServletUtils.getRepository(req).getRefDatabase();
    String repoName = ViewFilter.getView(req).getRepositoryName();
    Collection<Ref> refs = RefComparator.sort(refdb.getRefs(prefix).values());
    List<Map<String, String>> result = Lists.newArrayListWithCapacity(refs.size());

    for (Ref ref : refs) {
        String name = ref.getName().substring(prefix.length());
        boolean needPrefix = !ref.getName().equals(refdb.getRef(name).getName());
        result.add(ImmutableMap.of("url", GitilesView.log().copyFrom(req)
                .setRevision(Revision.unpeeled(needPrefix ? ref.getName() : name, ref.getObjectId())).toUrl(),
                "name", name));
    }/*from  w  w  w.j  a va2  s .c o  m*/

    return result;
}