use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class OpenInCommitViewerHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Repository repository = getRepository(event);
RevCommit commit = getSelectedCommit(event, repository);
if (commit != null)
CommitEditor.openQuiet((new RepositoryCommit(repository, commit)));
return null;
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class StashesMenu method createStashItem.
private static ActionContributionItem createStashItem(final Repository repo, final RevCommit stashCommit, int index) {
String text = MessageFormat.format(UIText.StashesMenu_StashItemText, Integer.valueOf(index), stashCommit.getShortMessage());
Action action = new Action(text) {
@Override
public void run() {
RepositoryCommit repositoryCommit = new RepositoryCommit(repo, stashCommit);
repositoryCommit.setStash(true);
CommitEditor.openQuiet(repositoryCommit);
}
};
return new ActionContributionItem(action);
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class CommitSearchQuery method walkRepository.
private void walkRepository(Repository repository, Pattern pattern, IProgressMonitor monitor) throws IOException {
try (RevWalk walk = new RevWalk(repository)) {
walk.setRetainBody(true);
List<RevCommit> commits = new LinkedList<>();
if (this.settings.isAllBranches()) {
for (Ref ref : repository.getRefDatabase().getRefs(Constants.R_HEADS).values()) if (!ref.isSymbolic())
commits.add(walk.parseCommit(ref.getObjectId()));
for (Ref ref : repository.getRefDatabase().getRefs(Constants.R_REMOTES).values()) if (!ref.isSymbolic())
commits.add(walk.parseCommit(ref.getObjectId()));
} else {
ObjectId headCommit = repository.resolve(Constants.HEAD);
if (headCommit != null)
commits.add(walk.parseCommit(headCommit));
}
if (!commits.isEmpty()) {
walk.markStart(commits);
for (RevCommit commit : walk) {
if (monitor.isCanceled())
throw new OperationCanceledException();
for (SearchMatcher matcher : this.matchers) if (matcher.matches(pattern, commit)) {
result.addResult(new RepositoryCommit(repository, commit));
break;
}
}
}
}
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class CommitSearchResultsPage method configureViewer.
private void configureViewer(StructuredViewer viewer) {
viewer.setComparator(new CommitSorter());
viewer.setContentProvider(new WorkbenchContentProvider() {
@Override
public Object[] getElements(Object element) {
if (getLayout() == FLAG_LAYOUT_TREE) {
Map<Repository, RepositoryMatch> repos = new HashMap<>();
for (Object inputElement : getInput().getElements()) {
RepositoryCommit commit = (RepositoryCommit) inputElement;
RepositoryMatch match = repos.get(commit.getRepository());
if (match == null) {
match = new RepositoryMatch(commit.getRepository());
repos.put(commit.getRepository(), match);
}
match.addCommit(commit);
}
return repos.values().toArray();
}
return super.getElements(element);
}
});
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new CommitResultLabelProvider(getLayout())));
}
Aggregations