use of git4idea.history.browser.GitHeavyCommit 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());
}
use of git4idea.history.browser.GitHeavyCommit in project intellij-community by JetBrains.
the class GitHistoryUtils method createCommit.
@NotNull
private static GitHeavyCommit createCommit(@NotNull Project project, @Nullable SymbolicRefsI refs, @NotNull VirtualFile root, @NotNull GitLogRecord record) throws VcsException {
final Collection<String> currentRefs = record.getRefs();
List<String> locals = new ArrayList<>();
List<String> remotes = new ArrayList<>();
List<String> tags = new ArrayList<>();
final String s = parseRefs(refs, currentRefs, locals, remotes, tags);
GitHeavyCommit gitCommit = new GitHeavyCommit(root, AbstractHash.create(record.getHash()), new SHAHash(record.getHash()), record.getAuthorName(), record.getCommitterName(), record.getDate(), record.getSubject(), record.getFullMessage(), new HashSet<>(Arrays.asList(record.getParentsHashes())), record.getFilePaths(root), record.getAuthorEmail(), record.getCommitterEmail(), tags, locals, remotes, record.parseChanges(project, root), record.getAuthorTimeStamp());
gitCommit.setCurrentBranch(s);
return gitCommit;
}
use of git4idea.history.browser.GitHeavyCommit in project intellij-community by JetBrains.
the class GitHistoryUtils method commitsDetails.
@Deprecated
@NotNull
public static List<GitHeavyCommit> commitsDetails(@NotNull Project project, @NotNull FilePath path, @Nullable SymbolicRefsI refs, @NotNull Collection<String> commitsIds) throws VcsException {
// adjust path using change manager
path = getLastCommitName(project, path);
VirtualFile root = GitUtil.getGitRoot(path);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME, COMMITTER_EMAIL, PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
h.setSilent(true);
h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8");
h.addParameters(new ArrayList<>(commitsIds));
String output = h.run();
final List<GitHeavyCommit> rc = new ArrayList<>();
for (GitLogRecord record : parser.parse(output)) {
final GitHeavyCommit gitCommit = createCommit(project, refs, root, record);
rc.add(gitCommit);
}
return rc;
}
Aggregations