@After
 public void clearGitResources() throws Exception {
   testRepo.disconnect(iProject);
   testRepo.dispose();
   repo = null;
   super.tearDown();
 }
Ejemplo n.º 2
0
  @Test
  public void squash() throws Exception {
    InteractiveHandler messageHandler =
        new InteractiveHandler() {
          public void prepareSteps(List<RebaseTodoLine> steps) {
            // not used
          }

          public String modifyCommitMessage(String commit) {
            return "squashed";
          }
        };

    List<RevCommit> commits = Arrays.asList(commit1, commit2, commit3);
    SquashCommitsOperation op =
        new SquashCommitsOperation(testRepository.getRepository(), commits, messageHandler);
    op.execute(new NullProgressMonitor());

    assertEquals(2, countCommitsInHead());

    LogCommand log = new Git(testRepository.getRepository()).log();
    Iterable<RevCommit> logCommits = log.call();
    RevCommit latestCommit = logCommits.iterator().next();
    assertEquals("squashed", latestCommit.getFullMessage());
  }
 @Before
 public void setUp() throws Exception {
   super.setUp();
   gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
   testRepository = new TestRepository(gitDir);
   repository = testRepository.getRepository();
   testRepository.connect(project.getProject());
   testRepository.commit("initial commit");
 }
  @Before
  public void setUp() throws Exception {
    super.setUp();

    TestRepository testRepo = new TestRepository(gitDir);
    testRepo.connect(project.project);
    repo = RepositoryMapping.getMapping(project.project).getRepository();

    // make initial commit
    new Git(repo).commit().setAuthor("JUnit", "*****@*****.**").setMessage("Initall commit").call();
  }
Ejemplo n.º 5
0
 private int countCommitsInHead() throws GitAPIException {
   LogCommand log = new Git(testRepository.getRepository()).log();
   Iterable<RevCommit> commits = log.call();
   int result = 0;
   for (Iterator i = commits.iterator(); i.hasNext(); ) {
     i.next();
     result++;
   }
   return result;
 }
Ejemplo n.º 6
0
  @Before
  public void setUp() throws Exception {
    super.setUp();
    gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    testRepository.connect(project.getProject());
    testRepository.createInitialCommit("initial");

    File file = testRepository.createFile(project.getProject(), "file-1");
    commit1 = testRepository.addAndCommit(project.getProject(), file, "commit 1");
    testRepository.appendFileContent(file, "file-2");
    commit2 = testRepository.addAndCommit(project.getProject(), file, "commit 2");
    testRepository.appendFileContent(file, "file-3");
    commit3 = testRepository.addAndCommit(project.getProject(), file, "commit 3");
  }
  @Test
  public void markAsMerged() throws Exception {
    GitSynchronizeData gsd = new GitSynchronizeData(repo, HEAD, HEAD, false);
    GitSynchronizeDataSet gsds = new GitSynchronizeDataSet(gsd);
    GitResourceVariantTreeSubscriber subscriber = new GitResourceVariantTreeSubscriber(gsds);

    String fileName = "src/Main.java";
    File file = testRepo.createFile(iProject, fileName);
    testRepo.appendContentAndCommit(iProject, file, "class Main {}", "some file");
    testRepo.addToIndex(iProject.getFile(".classpath"));
    testRepo.addToIndex(iProject.getFile(".project"));
    testRepo.commit("project files");

    IFile workspaceFile = testRepo.getIFile(iProject, file);

    ResourceMapping mapping = AdapterUtils.adapt(workspaceFile, ResourceMapping.class);
    ResourceMapping[] inputMappings = new ResourceMapping[] {mapping};
    SubscriberScopeManager manager =
        new SubscriberScopeManager("Scope", inputMappings, subscriber, true);

    testRepo.appendFileContent(file, "some changes");
    Status status = new Git(repo).status().call();
    assertEquals(0, status.getAdded().size());
    assertEquals(1, status.getModified().size());
    String repoRelativePath =
        testRepo.getRepoRelativePath(workspaceFile.getLocation().toPortableString());
    assertTrue(status.getModified().contains(repoRelativePath));

    GitSubscriberMergeContext mergeContext =
        new GitSubscriberMergeContext(subscriber, manager, gsds);
    IDiff node = new ResourceDiff(iProject.getFolder("src"), IDiff.CHANGE);
    mergeContext.markAsMerged(node, true, null);

    status = new Git(repo).status().call();
    assertEquals(1, status.getChanged().size());
    assertEquals(0, status.getModified().size());
    assertTrue(status.getChanged().contains(repoRelativePath));
  }
Ejemplo n.º 8
0
 @After
 public void tearDown() throws Exception {
   testRepository.dispose();
   super.tearDown();
 }