List of usage examples for org.eclipse.jgit.lib RefComparator INSTANCE
RefComparator INSTANCE
To view the source code for org.eclipse.jgit.lib RefComparator INSTANCE.
Click Source Link
From source file:com.google.gitiles.RefServlet.java
License:Open Source License
private static Ordering<Ref> branchComparator(Ref headLeaf) { if (headLeaf == null) { return Ordering.from(RefComparator.INSTANCE); }//from w ww . ja v a 2 s .c o m final String headLeafName = headLeaf.getName(); return new Ordering<Ref>() { @Override public int compare(@Nullable Ref left, @Nullable Ref right) { int l = isHead(left) ? 1 : 0; int r = isHead(right) ? 1 : 0; return r - l; } private final boolean isHead(Ref ref) { return ref != null && ref.getName().equals(headLeafName); } }.compound(RefComparator.INSTANCE); }
From source file:com.google.gitiles.RefServlet.java
License:Open Source License
private static Ordering<Ref> tagComparator(final TimeCache timeCache, final RevWalk walk) { return Ordering.natural().onResultOf(new Function<Ref, Long>() { @Override/*from w w w .ja va 2s. co m*/ public Long apply(Ref ref) { try { return timeCache.getTime(walk, ref.getObjectId()); } catch (IOException e) { throw new UncheckedExecutionException(e); } } }).reverse().compound(RefComparator.INSTANCE); }
From source file:net.erdfelt.android.sdkfido.git.internal.GitCloneCommand.java
License:Apache License
private Ref guessHEAD(final FetchResult result) { final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD); final List<Ref> availableRefs = new ArrayList<Ref>(); Ref head = null;/*from www.j ava2 s . c o m*/ for (final Ref r : result.getAdvertisedRefs()) { final String n = r.getName(); if (!n.startsWith(Constants.R_HEADS)) continue; availableRefs.add(r); if (idHEAD == null || head != null) continue; if (r.getObjectId().equals(idHEAD.getObjectId())) head = r; } Collections.sort(availableRefs, RefComparator.INSTANCE); if (idHEAD != null && head == null) head = idHEAD; return head; }
From source file:org.webcat.core.git.GitCloner.java
License:Open Source License
private Ref guessHead(FetchResult result) { Ref idHEAD = result.getAdvertisedRef(Constants.HEAD); List<Ref> availableRefs = new ArrayList<Ref>(); Ref head = null;// w w w. java 2 s. c o m for (Ref ref : result.getAdvertisedRefs()) { String name = ref.getName(); if (!name.startsWith(Constants.R_HEADS)) { continue; } availableRefs.add(ref); if (idHEAD == null || head != null) { continue; } if (ref.getObjectId().equals(idHEAD.getObjectId())) { head = ref; } } Collections.sort(availableRefs, RefComparator.INSTANCE); if (idHEAD != null && head == null) { head = idHEAD; } return head; }