use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.
the class FileHistoryFilterer method getCurrentRow.
private int getCurrentRow(@NotNull DataPack pack, @NotNull VisibleGraph<Integer> visibleGraph, @NotNull IndexDataGetter.FileNamesData fileIndexData) {
PermanentGraph<Integer> permanentGraph = pack.getPermanentGraph();
if (permanentGraph instanceof PermanentGraphImpl) {
CompressedRefs refs = pack.getRefsModel().getAllRefsByRoot().get(myRoot);
Optional<VcsRef> headOptional = refs.streamBranches().filter(br -> br.getName().equals("HEAD")).findFirst();
if (headOptional.isPresent()) {
VcsRef head = headOptional.get();
assert head.getRoot().equals(myRoot);
return findAncestorRowAffectingFile((PermanentGraphImpl<Integer>) permanentGraph, head.getCommitHash(), visibleGraph, fileIndexData);
}
}
return -1;
}
use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.
the class SimpleRefGroup method buildGroups.
public static void buildGroups(@NotNull MultiMap<VcsRefType, VcsRef> groupedRefs, boolean compact, boolean showTagNames, @NotNull List<RefGroup> result) {
if (groupedRefs.isEmpty())
return;
if (compact) {
VcsRef firstRef = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(groupedRefs.values()));
RefGroup group = ContainerUtil.getFirstItem(result);
if (group == null) {
result.add(new SimpleRefGroup(firstRef.getType().isBranch() || showTagNames ? firstRef.getName() : "", ContainerUtil.newArrayList(groupedRefs.values())));
} else {
group.getRefs().addAll(groupedRefs.values());
}
} else {
for (Map.Entry<VcsRefType, Collection<VcsRef>> entry : groupedRefs.entrySet()) {
if (entry.getKey().isBranch()) {
for (VcsRef ref : entry.getValue()) {
result.add(new SimpleRefGroup(ref.getName(), ContainerUtil.newArrayList(ref)));
}
} else {
result.add(new SimpleRefGroup(showTagNames ? ObjectUtils.notNull(ContainerUtil.getFirstItem(entry.getValue())).getName() : "", ContainerUtil.newArrayList(entry.getValue())));
}
}
}
}
use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.
the class GitBranchComparatorTest method check.
private void check(@NotNull String expectedBest, @NotNull Collection<VcsRef> givenBranches) throws IOException {
VcsRef actualBest = getTheMostPowerfulRef(givenBranches);
assertEquals(expect(expectedBest).get(0), actualBest);
}
use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.
the class GitRefManagerTest method given.
@NotNull
protected Collection<VcsRef> given(@NotNull String... refs) throws IOException {
Collection<VcsRef> result = ContainerUtil.newArrayList();
cd(myProjectRoot);
Hash hash = HashImpl.build(git("rev-parse HEAD"));
for (String refName : refs) {
if (isHead(refName)) {
result.add(ref(hash, "HEAD", GitRefManager.HEAD));
} else if (isRemoteBranch(refName)) {
git("update-ref refs/remotes/" + refName + " " + hash.asString());
result.add(ref(hash, refName, GitRefManager.REMOTE_BRANCH));
} else if (isTag(refName)) {
git("update-ref " + refName + " " + hash.asString());
result.add(ref(hash, GitBranchUtil.stripRefsPrefix(refName), GitRefManager.TAG));
} else {
git("update-ref refs/heads/" + refName + " " + hash.asString());
result.add(ref(hash, refName, GitRefManager.LOCAL_BRANCH));
}
}
setUpTracking(result);
myRepo.update();
return result;
}
use of com.intellij.vcs.log.VcsRef in project intellij-community by JetBrains.
the class RefParser method parseCommitRefs.
// e25b7d8f (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/heads/master)
public List<VcsRef> parseCommitRefs(@NotNull String input, @NotNull VirtualFile root) {
int firstSpaceIndex = input.indexOf(' ');
if (firstSpaceIndex < 0) {
return Collections.emptyList();
}
String strHash = input.substring(0, firstSpaceIndex);
Hash hash = HashImpl.build(strHash);
String refPaths = input.substring(firstSpaceIndex + 2, input.length() - 1);
String[] longRefPaths = refPaths.split("(, )|( -> )");
List<VcsRef> refs = new ArrayList<>();
for (String longRefPatch : longRefPaths) {
VcsRef ref = createRef(hash, longRefPatch, root);
if (ref != null) {
refs.add(ref);
}
}
return refs;
}
Aggregations