Package org.eclipse.egit.core.op

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


    addPage(optionsPage);
  }

  @Override
  public boolean performFinish() {
    final CreatePatchOperation operation = new CreatePatchOperation(db,
        commit);
    operation.setHeaderFormat(optionsPage.getSelectedHeaderFormat());
    operation.setContextLines(Integer.parseInt(optionsPage.contextLines.getText()));
    operation.setPathFilter(createPathFilter(resources));

    final File file = locationPage.getFile();

    if (!(file == null || validateFile(file)))
      return false;

    try {
      getContainer().run(true, true, new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor)
            throws InvocationTargetException {
          try {
            operation.execute(monitor);

            String content = operation.getPatchContent();
            if (file != null) {
              writeToFile(file, content);
              IFile[] files = ResourcesPlugin.getWorkspace()
                  .getRoot()
                  .findFilesForLocationURI(file.toURI());
View Full Code Here


      return patchFile;
    }

    private String createPatch(RevCommit commit) {
      Repository repository = input.getRepository();
      CreatePatchOperation operation = new CreatePatchOperation(
          repository, commit);
      operation.setHeaderFormat(DiffHeaderFormat.EMAIL);
      operation.setContextLines(CreatePatchOperation.DEFAULT_CONTEXT_LINES);
      try {
        operation.execute(null);
      } catch (CoreException e) {
        Activator.logError(NLS.bind(
            UIText.CommitGraphTable_UnableToCreatePatch, commit
                .getId().name()), e);
      }
      String patchContent = operation.getPatchContent();
      return patchContent;
    }
View Full Code Here

  @Test
  public void testSimpleGitPatch() throws Exception {
    RevCommit secondCommit = testRepository.appendContentAndCommit(
        project.getProject(), file, "another line", "2nd commit");

    CreatePatchOperation operation = new CreatePatchOperation(
        testRepository.getRepository(), secondCommit);

    operation.execute(new NullProgressMonitor());

    String patchContent = operation.getPatchContent();
    assertNotNull(patchContent);
    assertGitPatch(SIMPLE_GIT_PATCH_CONTENT, patchContent);

    // repeat setting the header format explicitly
    operation = new CreatePatchOperation(
        testRepository.getRepository(), secondCommit);

    operation.setHeaderFormat(DiffHeaderFormat.EMAIL);
    operation.execute(new NullProgressMonitor());

    patchContent = operation.getPatchContent();
    assertNotNull(patchContent);
    assertGitPatch(SIMPLE_GIT_PATCH_CONTENT, patchContent);
  }
View Full Code Here

  @Test
  public void testSimplePatch() throws Exception {
    RevCommit secondCommit = testRepository.appendContentAndCommit(
        project.getProject(), file, "another line", "2nd commit");

    CreatePatchOperation operation = new CreatePatchOperation(
        testRepository.getRepository(), secondCommit);

    operation.setHeaderFormat(DiffHeaderFormat.NONE);
    operation.execute(new NullProgressMonitor());

    String patchContent = operation.getPatchContent();
    assertNotNull(patchContent);
    assertPatch(SIMPLE_PATCH_CONTENT, patchContent);
  }
View Full Code Here

  @Test
  public void testOnelineHeaderPatch() throws Exception {
    RevCommit secondCommit = testRepository.appendContentAndCommit(
        project.getProject(), file, "another line", "2nd commit");

    CreatePatchOperation operation = new CreatePatchOperation(
        testRepository.getRepository(), secondCommit);

    operation.setHeaderFormat(DiffHeaderFormat.ONELINE);
    operation.execute(new NullProgressMonitor());

    String patchContent = operation.getPatchContent();
    assertNotNull(patchContent);
    assertPatch(SIMPLE_ONELINE_PATCH_CONTENT, patchContent);
  }
View Full Code Here

    assertPatch(SIMPLE_ONELINE_PATCH_CONTENT, patchContent);
  }

  @Test
  public void testFirstCommit() throws Exception {
    CreatePatchOperation operation = new CreatePatchOperation(
        testRepository.getRepository(), commit);

    operation.setHeaderFormat(DiffHeaderFormat.ONELINE);
    operation.execute(null);
    String patchContent = operation.getPatchContent();
    assertPatch("5d67e6eaa2464d15c4216a93a0e7180ec905a2bb new file\n"
        + "diff --git a/test-file b/test-file\n"
        + "new file mode 100644\nindex 0000000..e69de29\n"
        + "--- /dev/null\n" + "+++ b/test-file", patchContent);
  }
View Full Code Here

  }

  @SuppressWarnings("unused")
  @Test
  public void testNullCommit() throws Exception {
    new CreatePatchOperation(testRepository.getRepository(), null);
  }
View Full Code Here

  }

  @SuppressWarnings("unused")
  @Test(expected = IllegalArgumentException.class)
  public void testNullRepo() throws Exception {
    new CreatePatchOperation(null, commit);
  }
View Full Code Here

    new CreatePatchOperation(null, commit);
  }

  @Test(expected = IllegalStateException.class)
  public void testExecuteFirst() throws Exception {
    CreatePatchOperation operation = new CreatePatchOperation(
        testRepository.getRepository(), commit);
    operation.getPatchContent();
  }
View Full Code Here

  @Test
  public void testNullMonitor() throws Exception {
    RevCommit secondCommit = testRepository.appendContentAndCommit(
        project.getProject(), file, "another line", "2nd commit");
    CreatePatchOperation operation = new CreatePatchOperation(
        testRepository.getRepository(), secondCommit);
    operation.execute(null);
  }
View Full Code Here

TOP

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

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.