use of git4idea.history.browser.SymbolicRefs in project intellij-community by JetBrains.
the class GitCommittedChangeListProvider method getOneList.
@Override
public Pair<CommittedChangeList, FilePath> getOneList(final VirtualFile file, final VcsRevisionNumber number) throws VcsException {
FilePath filePath = VcsUtil.getFilePath(file);
final List<GitHeavyCommit> gitCommits = GitHistoryUtils.commitsDetails(myProject, filePath, new SymbolicRefs(), Collections.singletonList(number.asString()));
if (gitCommits.size() != 1) {
return null;
}
final GitHeavyCommit gitCommit = gitCommits.get(0);
CommittedChangeList commit = new GitCommittedChangeList(gitCommit.getDescription() + " (" + gitCommit.getShortHash().getString() + ")", gitCommit.getDescription(), gitCommit.getAuthor(), (GitRevisionNumber) number, new Date(gitCommit.getAuthorTime()), gitCommit.getChanges(), assertNotNull(GitVcs.getInstance(myProject)), true);
final Collection<Change> changes = commit.getChanges();
if (changes.size() == 1) {
Change change = changes.iterator().next();
return Pair.create(commit, ChangesUtil.getFilePath(change));
}
for (Change change : changes) {
if (change.getAfterRevision() != null && FileUtil.filesEqual(filePath.getIOFile(), change.getAfterRevision().getFile().getIOFile())) {
return Pair.create(commit, filePath);
}
}
final String afterTime = "--after=" + GitUtil.gitTime(gitCommit.getDate());
final List<VcsFileRevision> history = GitHistoryUtils.history(myProject, filePath, (VirtualFile) null, afterTime);
if (history.isEmpty()) {
return Pair.create(commit, filePath);
}
return Pair.create(commit, ((GitFileRevision) history.get(history.size() - 1)).getPath());
}
Aggregations