@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");
 }
 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;
 }