use of git4idea.GitCommit in project intellij-community by JetBrains.
the class GitBranchWorker method loadCommitsToCompare.
@NotNull
private Couple<List<GitCommit>> loadCommitsToCompare(@NotNull GitRepository repository, @NotNull final String branchName) {
final List<GitCommit> headToBranch;
final List<GitCommit> branchToHead;
try {
headToBranch = GitHistoryUtils.history(myProject, repository.getRoot(), ".." + branchName);
branchToHead = GitHistoryUtils.history(myProject, repository.getRoot(), branchName + "..");
} catch (VcsException e) {
// we treat it as critical and report an error
throw new GitExecutionException("Couldn't get [git log .." + branchName + "] on repository [" + repository.getRoot() + "]", e);
}
return Couple.of(headToBranch, branchToHead);
}
use of git4idea.GitCommit in project intellij-community by JetBrains.
the class GitOutgoingCommitsProvider method getOutgoingCommits.
@NotNull
@Override
public OutgoingResult getOutgoingCommits(@NotNull GitRepository repository, @NotNull PushSpec<GitPushSource, GitPushTarget> pushSpec, boolean initial) {
GitLocalBranch branch = pushSpec.getSource().getBranch();
String source = branch.equals(repository.getCurrentBranch()) ? HEAD : branch.getFullName();
GitPushTarget target = pushSpec.getTarget();
String destination = target.getBranch().getFullName();
try {
List<GitCommit> commits;
if (!target.isNewBranchCreated()) {
commits = GitHistoryUtils.history(myProject, repository.getRoot(), destination + ".." + source);
} else {
commits = GitHistoryUtils.history(myProject, repository.getRoot(), source, "--not", "--remotes=" + target.getBranch().getRemote().getName(), "--max-count=" + 1000);
}
return new OutgoingResult(commits, Collections.<VcsError>emptyList());
} catch (VcsException e) {
return new OutgoingResult(Collections.<VcsFullCommitDetails>emptyList(), Collections.singletonList(new VcsError(GitUtil.cleanupErrorPrefixes(e.getMessage()))));
}
}
use of git4idea.GitCommit in project intellij-community by JetBrains.
the class GitCommitListPanel method calcData.
// Make changes available for diff action
@Override
public void calcData(DataKey key, DataSink sink) {
if (VcsDataKeys.CHANGES.equals(key)) {
int[] rows = myTable.getSelectedRows();
if (rows.length != 1)
return;
int row = rows[0];
GitCommit gitCommit = myCommits.get(row);
// suppressing: inherited API
//noinspection unchecked
sink.put(key, ArrayUtil.toObjectArray(gitCommit.getChanges(), Change.class));
}
}
use of git4idea.GitCommit in project intellij-community by JetBrains.
the class GithubCreatePullRequestWorker method doLoadDiffInfo.
@NotNull
private DiffInfo doLoadDiffInfo(@NotNull final BranchInfo branch) throws VcsException {
// TODO: make cancelable and abort old speculative requests (when git4idea will allow to do so)
String currentBranch = myCurrentBranch;
String targetBranch = branch.getForkInfo().getRemoteName() + "/" + branch.getRemoteName();
List<GitCommit> commits1 = GitHistoryUtils.history(myProject, myGitRepository.getRoot(), ".." + targetBranch);
List<GitCommit> commits2 = GitHistoryUtils.history(myProject, myGitRepository.getRoot(), targetBranch + "..");
Collection<Change> diff = GitChangeUtils.getDiff(myProject, myGitRepository.getRoot(), targetBranch, myCurrentBranch, null);
GitCommitCompareInfo info = new GitCommitCompareInfo(GitCommitCompareInfo.InfoType.BRANCH_TO_HEAD);
info.put(myGitRepository, diff);
info.put(myGitRepository, Couple.of(commits1, commits2));
return new DiffInfo(info, currentBranch, targetBranch);
}
use of git4idea.GitCommit in project intellij-community by JetBrains.
the class GitCommitListPanel method generateColumnsInfo.
@NotNull
private ColumnInfo[] generateColumnsInfo(@NotNull List<GitCommit> commits) {
ItemAndWidth hash = new ItemAndWidth("", 0);
ItemAndWidth author = new ItemAndWidth("", 0);
ItemAndWidth time = new ItemAndWidth("", 0);
for (GitCommit commit : commits) {
hash = getMax(hash, getHash(commit));
author = getMax(author, getAuthor(commit));
time = getMax(time, getTime(commit));
}
return new ColumnInfo[] { new GitCommitColumnInfo("Hash", hash.myItem) {
@Override
public String valueOf(GitCommit commit) {
return getHash(commit);
}
}, new ColumnInfo<GitCommit, String>("Subject") {
@Override
public String valueOf(GitCommit commit) {
return commit.getSubject();
}
}, new GitCommitColumnInfo("Author", author.myItem) {
@Override
public String valueOf(GitCommit commit) {
return getAuthor(commit);
}
}, new GitCommitColumnInfo("Author time", time.myItem) {
@Override
public String valueOf(GitCommit commit) {
return getTime(commit);
}
} };
}
Aggregations