Search in sources :

Example 1 with RepositoryCommit

use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.

the class CommitEditorInputFactoryTest method shouldPersistAndRestoreCommit.

@Test
public void shouldPersistAndRestoreCommit() {
    RepositoryCommit repositoryCommit = new RepositoryCommit(repository, commit);
    new CommitEditorInput(repositoryCommit).saveState(memento);
    IAdaptable restored = new CommitEditorInputFactory().createElement(memento);
    assertNotNull(restored);
    assertThat(restored, instanceOf(CommitEditorInput.class));
    assertThat(repositoryCommit, isSameCommit(((CommitEditorInput) restored).getCommit()));
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) CommitEditorInputFactory(org.eclipse.egit.ui.internal.commit.CommitEditorInputFactory) CommitEditorInput(org.eclipse.egit.ui.internal.commit.CommitEditorInput) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) Test(org.junit.Test)

Example 2 with RepositoryCommit

use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.

the class CommitEditorInputFactoryTest method shouldPersistAndRestoreStashCommit.

@Test
public void shouldPersistAndRestoreStashCommit() {
    RepositoryCommit stashCommit = new RepositoryCommit(repository, commit);
    stashCommit.setStash(true);
    new CommitEditorInput(stashCommit).saveState(memento);
    IAdaptable restored = new CommitEditorInputFactory().createElement(memento);
    assertNotNull(restored);
    assertThat(restored, instanceOf(CommitEditorInput.class));
    assertThat(stashCommit, isSameCommit(((CommitEditorInput) restored).getCommit()));
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) CommitEditorInputFactory(org.eclipse.egit.ui.internal.commit.CommitEditorInputFactory) CommitEditorInput(org.eclipse.egit.ui.internal.commit.CommitEditorInput) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) Test(org.junit.Test)

Example 3 with RepositoryCommit

use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.

the class CommitEditorInputTest method testInput.

@Test
public void testInput() {
    RepositoryCommit repoCommit = new RepositoryCommit(repository, commit);
    CommitEditorInput input = new CommitEditorInput(repoCommit);
    assertNotNull(input.getImageDescriptor());
    assertNotNull(input.getToolTipText());
    assertNotNull(input.getName());
    assertEquals(repoCommit, input.getCommit());
    assertNotNull(input.getPersistable());
}
Also used : CommitEditorInput(org.eclipse.egit.ui.internal.commit.CommitEditorInput) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) Test(org.junit.Test)

Example 4 with RepositoryCommit

use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.

the class CommitEditorTest method showAnnotations.

@Test
public void showAnnotations() 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());
    SWTBotEditor commitEditor = bot.activeEditor();
    SWTBotTable table = commitEditor.bot().table(1);
    assertTrue(table.rowCount() > 0);
    table.select(0);
    ContextMenuHelper.clickContextMenuSync(table, UIText.CommitFileDiffViewer_ShowAnnotationsMenuLabel);
    TestUtil.joinJobs(JobFamilies.BLAME);
    assertFalse(commitEditor.getReference().equals(bot.activeEditor().getReference()));
    final String content = getTestFileContent();
    // Change working directory content to validate blame opens HEAD
    setTestFileContent("updated content" + System.nanoTime());
    assertEquals(content, bot.activeEditor().toTextEditor().getText());
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) AtomicReference(java.util.concurrent.atomic.AtomicReference) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) Test(org.junit.Test)

Example 5 with RepositoryCommit

use of org.eclipse.egit.ui.internal.commit.RepositoryCommit in project egit by eclipse.

the class CherryPickHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    RevCommit commit = getSelectedCommit(event);
    Repository repo = getRepository(event);
    if (repo == null)
        return null;
    final IStructuredSelection selected = new StructuredSelection(new RepositoryCommit(repo, commit));
    CommonUtils.runCommand(org.eclipse.egit.ui.internal.commit.command.CherryPickHandler.ID, selected);
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

RepositoryCommit (org.eclipse.egit.ui.internal.commit.RepositoryCommit)34 RevCommit (org.eclipse.jgit.revwalk.RevCommit)15 Repository (org.eclipse.jgit.lib.Repository)13 Test (org.junit.Test)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 IOException (java.io.IOException)6 ExecutionException (org.eclipse.core.commands.ExecutionException)6 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 ArrayList (java.util.ArrayList)5 ObjectId (org.eclipse.jgit.lib.ObjectId)5 UIText (org.eclipse.egit.ui.internal.UIText)4 RevWalk (org.eclipse.jgit.revwalk.RevWalk)4 IEditorPart (org.eclipse.ui.IEditorPart)4 CommitEditorInput (org.eclipse.egit.ui.internal.commit.CommitEditorInput)3 PartInitException (org.eclipse.ui.PartInitException)3 Map (java.util.Map)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2