Package org.eclipse.egit.core.op

Examples of org.eclipse.egit.core.op.CommitOperation


    if (!UIUtils.saveAllEditors(currentRepository,
        UIText.StagingView_cancelCommitAfterSaving))
      return;

    String commitMessage = commitMessageComponent.getCommitMessage();
    CommitOperation commitOperation = null;
    try {
      commitOperation = new CommitOperation(currentRepository,
          commitMessageComponent.getAuthor(),
          commitMessageComponent.getCommitter(),
          commitMessage);
    } catch (CoreException e) {
      Activator.handleError(UIText.StagingView_commitFailed, e, true);
      return;
    }
    if (amendPreviousCommitAction.isChecked())
      commitOperation.setAmending(true);
    commitOperation.setComputeChangeId(addChangeIdAction.isChecked());
    Job commitJob = new CommitJob(currentRepository, commitOperation)
      .setOpenCommitEditor(openNewCommitsAction.isChecked())
      .setPushUpstream(pushUpstream);

    // don't allow to do anything as long as commit is in progress
View Full Code Here


    commitDialog.setCommitMessage(commitHelper.getCommitMessage());

    if (commitDialog.open() != IDialogConstants.OK_ID)
      return false;

    final CommitOperation commitOperation;
    try {
      commitOperation= new CommitOperation(
          repo,
          commitDialog.getSelectedFiles(), notTracked, commitDialog.getAuthor(),
          commitDialog.getCommitter(), commitDialog.getCommitMessage());
    } catch (CoreException e1) {
      Activator.handleError(UIText.CommitUI_commitFailed, e1, true);
      return false;
    }
    if (commitDialog.isAmending())
      commitOperation.setAmending(true);
    commitOperation.setComputeChangeId(commitDialog.getCreateChangeId());
    commitOperation.setCommitAll(commitHelper.isMergedResolved);
    if (commitHelper.isMergedResolved)
      commitOperation.setRepository(repo);
    Job commitJob = new CommitJob(repo, commitOperation).
        setPushUpstream(commitDialog.isPushRequested());
    commitJob.schedule();

    return true;
View Full Code Here

    IFile[] commitables = new IFile[] { firstProject.getFile(".project"),
        textFile, textFile2, secondtextFile, secondtextFile2 };
    ArrayList<IFile> untracked = new ArrayList<IFile>();
    untracked.addAll(Arrays.asList(commitables));
    // commit to stable
    CommitOperation op = new CommitOperation(commitables,
        untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER,
        "Initial commit");
    op.execute(null);

    // now create a stable branch (from master)
    createStableBranch(myRepository);
    // and check in some stuff into master again
    touchAndSubmit(null);
View Full Code Here

    ArrayList<IFile> untracked = new ArrayList<IFile>();
    untracked.addAll(Arrays.asList(commitables));
    String message = commitMessage;
    if (message == null)
      message = newContent;
    CommitOperation op = new CommitOperation(commitables,
        untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER,
        message);
    op.execute(null);
  }
View Full Code Here

    if (!prj.isAccessible())
      throw new IllegalStateException("No project to touch");
    IFile[] commitables = new IFile[] { file };
    ArrayList<IFile> untracked = new ArrayList<IFile>();
    untracked.addAll(Arrays.asList(commitables));
    CommitOperation op = new CommitOperation(commitables,
        untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER,
        commitMessage);
    op.execute(null);
  }
View Full Code Here

    IFile[] commitables = new IFile[] { gitignore };
    ArrayList<IFile> untracked = new ArrayList<IFile>();
    untracked.addAll(Arrays.asList(commitables));

    CommitOperation op = new CommitOperation(commitables,
        untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER,
        "Add .gitignore file");
    op.execute(null);
  }
View Full Code Here

  @Test
  public void testCommitAddedToIndexDeletedInWorkspace() throws Exception {
    testUtils.addFileToProject(project.getProject(), "foo/a.txt", "some text");
    resources.add(project.getProject().getFolder("foo"));
    new AddToIndexOperation(resources).execute(null);
    CommitOperation commitOperation = new CommitOperation(null, null, TestUtils.AUTHOR, TestUtils.COMMITTER, "first commit");
    commitOperation.setCommitAll(true);
    commitOperation.setRepository(repository);
    commitOperation.execute(null);

    testUtils.addFileToProject(project.getProject(), "zar/b.txt", "some text");
    resources.add(project.getProject().getFolder("zar"));
    new AddToIndexOperation(resources).execute(null);
    IFile zarFile = project.getProject().getFile("zar/b.txt");
    IPath zarFilePath = zarFile.getLocation();
    // delete file and refresh. Deleting using the resource would trigger
    // GitMoveDeleteHook which removes the file from the index
    assertTrue("could not delete file " + zarFilePath.toOSString(),
        zarFilePath.toFile().delete());
    zarFile.refreshLocal(0, null);

    assertFalse(project.getProject().getFile("zar/b.txt").exists());

    IFile[] filesToCommit = new IFile[] { project.getProject().getFile("zar/b.txt") };
    commitOperation = new CommitOperation(filesToCommit, null, TestUtils.AUTHOR, TestUtils.COMMITTER, "first commit");
    commitOperation.setRepository(repository);
    try {
      commitOperation.execute(null);
      // TODO this is very ugly. CommitCommand should be extended
      // not to throw an JGitInternalException in case of an empty
      // commit
      fail("expected CoreException");
    } catch (CoreException e) {
View Full Code Here

    testUtils.addFileToProject(project.getProject(),
        "sub/b.txt", "some text");

    resources.add(project.getProject().getFolder("sub"));
    new AddToIndexOperation(resources).execute(null);
    CommitOperation commitOperation = new CommitOperation(null, null, TestUtils.AUTHOR,
        TestUtils.COMMITTER, "first commit");
    commitOperation.setCommitAll(true);
    commitOperation.setRepository(repository);
    commitOperation.execute(null);

    Git git = new Git(repository);
    Iterator<RevCommit> commits = git.log().call().iterator();
    RevCommit firstCommit = commits.next();
    assertTrue(firstCommit.getCommitTime() > 0);

    assertEquals("first commit", firstCommit.getFullMessage());

    testUtils.changeContentOfFile(project.getProject(), file1, "changed text");

    commitOperation = new CommitOperation(null, null, TestUtils.AUTHOR,
        TestUtils.COMMITTER, "second commit");
    commitOperation.setCommitAll(true);
    commitOperation.setRepository(repository);
    commitOperation.execute(null);

    git = new Git(repository);
    commits = git.log().call().iterator();
    RevCommit secondCommit = commits.next();
    assertTrue(secondCommit.getCommitTime() > 0);
View Full Code Here

    testUtils.addFileToProject(project.getProject(),
        "sub2/b.txt", "some text");
    resources.add(project.getProject().getFolder("sub1"));
    resources.add(project.getProject().getFolder("sub2"));
    new AddToIndexOperation(resources).execute(null);
    CommitOperation commitOperation = new CommitOperation(null, null, TestUtils.AUTHOR,
        TestUtils.COMMITTER, "first commit");
    commitOperation.setCommitAll(true);
    commitOperation.setRepository(repository);
    commitOperation.execute(null);

    Git git = new Git(repository);
    Iterator<RevCommit> commits = git.log().call().iterator();
    RevCommit secondCommit = commits.next();
    TreeWalk treeWalk = new TreeWalk(repository);
    treeWalk.addTree(secondCommit.getTree().getId());
    treeWalk.setRecursive(true);
    treeWalk.setPostOrderTraversal(true);
    assertTrue(treeWalk.next());
    assertEquals("sub1/a.txt", treeWalk.getPathString());
    assertTrue(treeWalk.next());
    assertEquals("sub1", treeWalk.getPathString());
    assertTrue(treeWalk.next());
    assertEquals("sub2/b.txt", treeWalk.getPathString());
    assertTrue(treeWalk.next());
    assertEquals("sub2", treeWalk.getPathString());
    assertFalse(treeWalk.next());

    project.getProject().getFolder("sub2").delete(IResource.FORCE, null);
    IFile[] filesToCommit = { project.getProject().getFile("sub2/b.txt") };
    ArrayList<IFile> notIndexed = new ArrayList<IFile>();
    notIndexed.add(filesToCommit[0]);
    ArrayList<IFile> notTracked = new ArrayList<IFile>();
    commitOperation = new CommitOperation(filesToCommit, notTracked, TestUtils.AUTHOR, TestUtils.COMMITTER, "second commit");
    commitOperation.setCommitAll(false);
    commitOperation.execute(null);

    git = new Git(repository);
    commits = git.log().call().iterator();
    secondCommit = commits.next();
    treeWalk = new TreeWalk(repository);
View Full Code Here

    IFile fileB = testUtils.addFileToProject(project.getProject(),
        "foo/b.txt", "some text");
    testUtils.addFileToProject(project.getProject(), "foo/c.txt",
        "some text");
    IFile[] filesToCommit = { fileA, fileB };
    CommitOperation commitOperation = new CommitOperation(filesToCommit,
        Arrays.asList(filesToCommit), TestUtils.AUTHOR,
        TestUtils.COMMITTER, "first commit");
    commitOperation.execute(null);
    testUtils.assertRepositoryContainsFiles(repository, getRepoRelativePaths(filesToCommit));
  }
View Full Code Here

TOP

Related Classes of org.eclipse.egit.core.op.CommitOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.