Package org.eclipse.egit.core.op

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


  /**
   * Run the operation.
   */
  public void run() {
    final IgnoreOperation operation = new IgnoreOperation(paths);
    String jobname = UIText.IgnoreActionHandler_addToGitignore;
    Job job = new Job(jobname) {
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        try {
          operation.execute(monitor);
        } catch (CoreException e) {
          return Activator.createErrorStatus(e.getStatus()
              .getMessage(), e);
        }
        if (operation.isGitignoreOutsideWSChanged())
          refresh();
        return Status.OK_STATUS;
      }
    };
    job.setUser(true);
    job.setRule(operation.getSchedulingRule());
    job.schedule();
  }
View Full Code Here


  }

  @Test
  public void testIgnoreFolder() throws Exception {
    IFolder binFolder = project.getProject().getFolder("bin");
    IgnoreOperation operation = executeIgnore(binFolder.getLocation());

    String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
    assertEquals("/bin/\n", content);
    assertFalse(operation.isGitignoreOutsideWSChanged());
  }
View Full Code Here

  }

  @Test
  public void testIgnoreFile() throws Exception {
    IFile aFile = project.createFile("aFile.txt", new byte[0]);
    IgnoreOperation operation = executeIgnore(aFile.getLocation());
    String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
    assertEquals("/aFile.txt\n", content);
    assertFalse(operation.isGitignoreOutsideWSChanged());
  }
View Full Code Here

  }

  @Test
  public void testIgnoreFileCancel() throws Exception {
    IFolder binFolder = project.getProject().getFolder("bin");
    IgnoreOperation operation = new IgnoreOperation(Arrays.asList(binFolder.getLocation()));
    NullProgressMonitor monitor = new NullProgressMonitor();
    monitor.setCanceled(true);
    operation.execute(monitor);

    assertFalse(project.getProject().getFile(Constants.GITIGNORE_FILENAME).exists());
  }
View Full Code Here


  @Test
  public void testSchedulingRule() throws Exception {
    IFolder binFolder = project.getProject().getFolder("bin");
    IgnoreOperation operation = executeIgnore(binFolder.getLocation());

    assertNotNull(operation.getSchedulingRule());
  }
View Full Code Here

    assertEquals("/bin/\n/src/\n", content);
  }

  @Test
  public void testIgnoreProject() throws Exception {
    IgnoreOperation operation = executeIgnore(
        project.getProject().getLocation());

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    File rootFile = root.getRawLocation().toFile();
    File ignoreFile = new File(rootFile, Constants.GITIGNORE_FILENAME);
    String content = testUtils.slurpAndClose(ignoreFile.toURI().toURL()
        .openStream());
    assertEquals("/" + project.getProject().getName() + "/\n", content);
    assertTrue(operation.isGitignoreOutsideWSChanged());
  }
View Full Code Here

    assertFalse(ignore.exists());
    ignore.create(new ByteArrayInputStream(existing.getBytes("UTF-8")),
        IResource.FORCE, new NullProgressMonitor());

    IFolder binFolder = project.getProject().getFolder("bin");
    IgnoreOperation operation = executeIgnore(binFolder.getLocation());

    String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
    assertEquals(existing + "\n/bin/\n", content);
    assertFalse(operation.isGitignoreOutsideWSChanged());
  }
View Full Code Here

  }

  @Test
  public void testIgnoreWithResource() throws Exception {
    IFolder binFolder = project.getProject().getFolder("bin");
    @SuppressWarnings("deprecation")
    IgnoreOperation operation = new IgnoreOperation(new IResource[] {binFolder});
    operation.execute(new NullProgressMonitor());

    String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
    assertEquals("/bin/\n", content);
  }
View Full Code Here

    try {
      // Use Project-1 to create folder, Project-2 to get file to try to
      // confuse any caches in workspace root (location -> IResource).
      project.createFolder("Project-2/please");
      IFile ignoreme = nested.createFile("please/ignoreme", new byte[0]);
      IgnoreOperation operation = executeIgnore(ignoreme.getLocation());
      String content = nested.getFileContent("please/.gitignore");
      assertEquals("/ignoreme\n", content);
      assertFalse(operation.isGitignoreOutsideWSChanged());
    } finally {
      nested.dispose();
    }
  }
View Full Code Here

      nested.dispose();
    }
  }

  private IgnoreOperation executeIgnore(IPath... paths) throws Exception {
    final IgnoreOperation operation = new IgnoreOperation(Arrays.asList(paths));
    Job job = new Job("Ignoring resources for test") {
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        try {
          operation.execute(monitor);
        } catch (CoreException e) {
          return e.getStatus();
        }
        return Status.OK_STATUS;
      }
    };
    job.setRule(operation.getSchedulingRule());
    job.schedule();
    job.join();
    if (!job.getResult().isOK())
      fail("Ignore job failed: " + job.getResult());
    return operation;
View Full Code Here

TOP

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

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.