use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class CommitEditorTest method openAllEditorPagesOnValidCommit.
@Test
public void openAllEditorPagesOnValidCommit() throws Exception {
final AtomicReference<IEditorPart> editorRef = new AtomicReference<>();
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
RepositoryCommit repoCommit = new RepositoryCommit(repository, commit);
editorRef.set(CommitEditor.openQuiet(repoCommit));
}
});
assertNotNull(editorRef.get());
IEditorPart editor = editorRef.get();
assertTrue(editor instanceof CommitEditor);
RepositoryCommit adaptedCommit = Utils.getAdapter(editor, RepositoryCommit.class);
assertNotNull(adaptedCommit);
assertEquals(commit, adaptedCommit.getRevCommit());
assertEquals(repository.getDirectory(), adaptedCommit.getRepository().getDirectory());
IEditorInput input = editor.getEditorInput();
assertNotNull(input);
SWTBotMultiPageEditor botEditor = bot.multipageEditorByTitle(input.getName());
assertNotNull(botEditor);
assertTrue(botEditor.getPageCount() > 1);
for (String name : botEditor.getPagesTitles()) botEditor.activatePage(name);
botEditor.close();
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class RepositoryCommitTest method testDiffs.
@Test
public void testDiffs() throws Exception {
RepositoryCommit repoCommit = new RepositoryCommit(repository, commit);
FileDiff[] diffs = repoCommit.getDiffs();
assertNotNull(diffs);
assertTrue(diffs.length > 0);
for (FileDiff diff : diffs) assertNotNull(diff);
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class RepositoryCommitTest method testAdapters.
@Test
public void testAdapters() throws Exception {
RepositoryCommit repoCommit = new RepositoryCommit(repository, commit);
assertEquals(repository, repoCommit.getAdapter(Repository.class));
assertEquals(commit, repoCommit.getAdapter(RevCommit.class));
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class RepositoryCommitTest method testGetters.
@Test
public void testGetters() {
RepositoryCommit repoCommit = new RepositoryCommit(repository, commit);
assertEquals(repository, repoCommit.getRepository());
assertEquals(commit, repoCommit.getRevCommit());
assertNotNull(repoCommit.getRepositoryName());
assertNotNull(repoCommit.abbreviate());
}
use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.
the class RevertHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
List<RepositoryCommit> repoCommits = getCommits(event);
Repository repo = repoCommits.get(0).getRepository();
final Shell shell = getPart(event).getSite().getShell();
final List<RevCommit> commits = new ArrayList<>();
for (RepositoryCommit repoCommit : repoCommits) commits.add(repoCommit.getRevCommit());
final RevertCommitOperation op = new RevertCommitOperation(repo, commits);
Job job = new WorkspaceJob(MessageFormat.format(UIText.RevertHandler_JobName, Integer.valueOf(commits.size()))) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
op.execute(monitor);
RevCommit newHead = op.getNewHead();
List<Ref> revertedRefs = op.getRevertedRefs();
if (newHead != null && revertedRefs.isEmpty())
showRevertedDialog(shell);
if (newHead == null) {
RevCommit newestUnmergedCommit = null;
for (RevCommit commit : commits) {
if (!contains(revertedRefs, commit)) {
newestUnmergedCommit = commit;
break;
}
}
showFailureDialog(shell, newestUnmergedCommit, op.getFailingResult());
}
} catch (CoreException e) {
Activator.handleError(UIText.RevertOperation_InternalError, e, true);
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.REVERT_COMMIT.equals(family))
return true;
return super.belongsTo(family);
}
};
job.setUser(true);
job.setRule(op.getSchedulingRule());
job.schedule();
return null;
}
Aggregations