use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class RevertHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final List<RevCommit> commits = getSelectedCommits(event);
Repository repo = getRepository(event);
if (repo == null)
return null;
try {
boolean allOnCurrentBranch = true;
for (RevCommit commit : commits) {
if (!CommitUtil.isCommitInCurrentBranch(commit, repo)) {
allOnCurrentBranch = false;
break;
}
}
if (!allOnCurrentBranch) {
MessageDialog.openError(HandlerUtil.getActiveShellChecked(event), UIText.RevertHandler_Error_Title, UIText.RevertHandler_CommitsNotOnCurrentBranch);
return null;
}
} catch (IOException e) {
throw new ExecutionException(UIText.RevertHandler_ErrorCheckingIfCommitsAreOnCurrentBranch, e);
}
BasicConfigurationDialog.show(repo);
List<RepositoryCommit> repositoryCommits = new ArrayList<>();
for (RevCommit commit : commits) repositoryCommits.add(new RepositoryCommit(repo, commit));
final IStructuredSelection selected = new StructuredSelection(repositoryCommits);
CommonUtils.runCommand(org.eclipse.egit.ui.internal.commit.command.RevertHandler.ID, selected);
return null;
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class SquashHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Repository repository = getRepository(event);
List<RevCommit> commits = getSelectedCommits(event);
try {
if (!CommitUtil.areCommitsInCurrentBranch(commits, repository)) {
MessageDialog.openError(getPart(event).getSite().getShell(), UIText.SquashHandler_Error_Title, UIText.SquashHandler_CommitsNotOnCurrentBranch);
return null;
}
} catch (IOException e) {
throw new ExecutionException(UIText.SquashHandler_ErrorCheckingIfCommitsAreOnCurrentBranch, e);
}
List<RepositoryCommit> repositoryCommits = new ArrayList<>();
for (RevCommit commit : commits) repositoryCommits.add(new RepositoryCommit(repository, commit));
final IStructuredSelection selected = new StructuredSelection(repositoryCommits);
CommonUtils.runCommand(org.eclipse.egit.ui.internal.commit.command.SquashHandler.ID, selected);
return null;
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class CommitResultLabelProvider method getStyledText.
/**
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
*/
@Override
public StyledString getStyledText(Object element) {
StyledString styled = new StyledString();
if (element instanceof RepositoryCommit) {
RepositoryCommit commit = (RepositoryCommit) element;
RevCommit revCommit = commit.getRevCommit();
styled.append(MessageFormat.format(UIText.CommitResultLabelProvider_SectionMessage, commit.abbreviate(), revCommit.getShortMessage()));
PersonIdent author = revCommit.getAuthorIdent();
if (author != null)
styled.append(MessageFormat.format(UIText.CommitResultLabelProvider_SectionAuthor, author.getName(), dateFormatter.formatDate(author)), StyledString.QUALIFIER_STYLER);
if (layout == AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT)
styled.append(MessageFormat.format(UIText.CommitResultLabelProvider_SectionRepository, commit.getRepositoryName()), StyledString.DECORATIONS_STYLER);
} else if (element instanceof RepositoryMatch) {
RepositoryMatch repository = (RepositoryMatch) element;
styled.append(repository.getLabel(repository));
// $NON-NLS-1$
styled.append(" - ", StyledString.QUALIFIER_STYLER);
styled.append(repository.getRepository().getDirectory().getAbsolutePath(), StyledString.QUALIFIER_STYLER);
styled.append(// $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
" ({0})", Integer.valueOf(repository.getMatchCount())), StyledString.COUNTER_STYLER);
}
return styled;
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class CommitSearchQueryTest method validateResult.
private void validateResult(RevCommit expectedCommit, Repository expectedRepository, ISearchResult result) {
assertNotNull(result);
assertTrue(result instanceof CommitSearchResult);
CommitSearchResult commitResult = (CommitSearchResult) result;
assertEquals(1, commitResult.getMatchCount());
Object[] elements = commitResult.getElements();
assertNotNull(elements);
assertEquals(1, elements.length);
assertTrue(elements[0] instanceof RepositoryCommit);
RepositoryCommit repoCommit = (RepositoryCommit) elements[0];
assertEquals(expectedRepository.getDirectory(), repoCommit.getRepository().getDirectory());
assertEquals(expectedCommit, repoCommit.getRevCommit());
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class OpenCommand method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final List<RepositoryTreeNode> nodes = getSelectedNodes(event);
if (nodes.isEmpty())
return null;
final RepositoryTreeNode node = nodes.get(0);
if (node instanceof RefNode || node instanceof TagNode)
return new CheckoutCommand().execute(event);
if (node instanceof FileNode)
return new OpenInEditorCommand().execute(event);
if (node instanceof StashedCommitNode) {
RepositoryCommit repositoryCommit = new RepositoryCommit(node.getRepository(), ((StashedCommitNode) node).getObject());
repositoryCommit.setStash(true);
CommitEditor.openQuiet(repositoryCommit);
}
return null;
}
Aggregations