Search in sources :

Example 1 with EditCommitOperation

use of org.eclipse.egit.core.op.EditCommitOperation in project egit by eclipse.

the class EditCommitOperationTest method edit.

@Test
public void edit() throws Exception {
    EditCommitOperation op = new EditCommitOperation(testRepository.getRepository(), firstCommit);
    op.execute(new NullProgressMonitor());
    assertEquals(RepositoryState.REBASING_INTERACTIVE, testRepository.getRepository().getRepositoryState());
    List<RebaseTodoLine> todos = testRepository.getRepository().readRebaseTodo(GIT_REBASE_TODO, false);
    assertEquals(1, todos.size());
    assertEquals(RebaseTodoLine.Action.PICK, todos.get(0).getAction());
    assertTrue(secondCommit.getId().startsWith(todos.get(0).getCommit()));
    ObjectId headId = testRepository.getRepository().resolve(Constants.HEAD);
    assertEquals(firstCommit.getId(), headId);
}
Also used : RebaseTodoLine(org.eclipse.jgit.lib.RebaseTodoLine) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) EditCommitOperation(org.eclipse.egit.core.op.EditCommitOperation) ObjectId(org.eclipse.jgit.lib.ObjectId) Test(org.junit.Test)

Example 2 with EditCommitOperation

use of org.eclipse.egit.core.op.EditCommitOperation in project egit by eclipse.

the class EditHandler method editCommit.

/**
 * @param commit
 * @param repo
 * @param shell
 * @return true, if edit was started, false if user aborted
 */
public static boolean editCommit(RevCommit commit, Repository repo, Shell shell) {
    try {
        if (!UIRepositoryUtils.handleUncommittedFiles(repo, shell))
            return false;
    } catch (GitAPIException e) {
        Activator.logError(e.getMessage(), e);
        return false;
    }
    final EditCommitOperation op = new EditCommitOperation(repo, commit);
    JobUtil.scheduleUserWorkspaceJob(op, MessageFormat.format(UIText.EditHandler_JobName, commit.name()), JobFamilies.EDIT);
    return true;
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) EditCommitOperation(org.eclipse.egit.core.op.EditCommitOperation)

Aggregations

EditCommitOperation (org.eclipse.egit.core.op.EditCommitOperation)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 RebaseTodoLine (org.eclipse.jgit.lib.RebaseTodoLine)1 Test (org.junit.Test)1