Package org.eclipse.egit.core.op

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


      // ignore, we will not add the files in case the user
      // cancels the scope operation
      return null;
    }

    final AddToIndexOperation operation = new AddToIndexOperation(
        resourcesInScope);
    String jobname = UIText.AddToIndexAction_addingFiles;
    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);
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.ADD_TO_INDEX.equals(family))
          return true;

        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    job.setRule(operation.getSchedulingRule());
    job.schedule();
    return null;
  }
View Full Code Here


  }

  public void markAsMerged(IDiff node, boolean inSyncHint,
      IProgressMonitor monitor) throws CoreException {
    IResource resource = getDiffTree().getResource(node);
    AddToIndexOperation operation = new AddToIndexOperation(
        new IResource[] { resource });
    operation.execute(monitor);
  }
View Full Code Here

  }

  protected static void stage(IFile file) throws Exception {
    ArrayList<IFile> unstaged = new ArrayList<IFile>();
    unstaged.addAll(Arrays.asList(new IFile[] { file }));
    AddToIndexOperation op = new AddToIndexOperation(unstaged);
    op.execute(null);
  }
View Full Code Here

    assertFalse(testRepository.inIndex(file1.getLocation()
        .toPortableString()));

    resources.add(file1);
    new AddToIndexOperation(resources).execute(null);

    assertTrue(testRepository.inIndex(file1.getLocation()
        .toPortableString()));
  }
View Full Code Here

        .toPortableString()));
    assertFalse(testRepository.inIndex(file2.getLocation()
        .toPortableString()));

    resources.add(project.getProject().getFolder("sub"));
    new AddToIndexOperation(resources).execute(null);

    assertTrue(testRepository.inIndex(file1.getLocation()
        .toPortableString()));
    assertTrue(testRepository.inIndex(file2.getLocation()
        .toPortableString()));
View Full Code Here

  public void testAddFile() throws Exception {
    IFile file1 = testUtils.addFileToProject(project.getProject(), "a.txt",
        "some text");

    resources.add(file1);
    new AddToIndexOperation(resources).execute(null);

    testRepository.commit("first commit");

    assertEquals(file1.getLocalTimeStamp(),
        testRepository.lastModifiedInIndex(file1.getLocation()
            .toPortableString()));

    Thread.sleep(1000);
    file1.setContents(
        new ByteArrayInputStream("other text".getBytes(project.project
            .getDefaultCharset())), 0, null);

    assertFalse(file1.getLocalTimeStamp() == testRepository
        .lastModifiedInIndex(file1.getLocation().toPortableString()));

    new AddToIndexOperation(resources).execute(null);

    assertTrue(testRepository.inIndex(file1.getLocation()
        .toPortableString()));
    // does not work yet due to the racy git problem: DirCache.writeTo
    // smudges the
View Full Code Here

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

    resources.add(project.getProject().getFolder("sub"));
    new AddToIndexOperation(resources).execute(null);

    testRepository.commit("first commit");

    assertEquals(file1.getLocalTimeStamp(),
        testRepository.lastModifiedInIndex(file1.getLocation()
            .toPortableString()));

    Thread.sleep(1000);

    file1.setContents(
        new ByteArrayInputStream("other text".getBytes(project.project
            .getDefaultCharset())), 0, null);
    file2.setContents(
        new ByteArrayInputStream("other text".getBytes(project.project
            .getDefaultCharset())), 0, null);

    assertFalse(file1.getLocalTimeStamp() == testRepository
        .lastModifiedInIndex(file1.getLocation().toPortableString()));
    assertFalse(file2.getLocalTimeStamp() == testRepository
        .lastModifiedInIndex(file1.getLocation().toPortableString()));

    new AddToIndexOperation(resources).execute(null);

    assertTrue(testRepository.inIndex(file1.getLocation()
        .toPortableString()));
    assertTrue(testRepository.inIndex(file2.getLocation()
        .toPortableString()));
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(),
View Full Code Here

        "sub/a.txt", "some text");
    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);
View Full Code Here

        "sub1/a.txt", "some text");
    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);
View Full Code Here

TOP

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

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.