@Test
public void finishFeatureWithSquash() throws Exception
{
Git git = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());
JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();
flow.featureStart("my-feature").call();
//create a new commit
File junkFile = new File(git.getRepository().getWorkTree(), "junk.txt");
FileUtils.writeStringToFile(junkFile, "I am junk");
git.add().addFilepattern(junkFile.getName()).call();
RevCommit commit = git.commit().setMessage("committing junk file").call();
//create second commit
File junkFile2 = new File(git.getRepository().getWorkTree(), "junk2.txt");
FileUtils.writeStringToFile(junkFile2, "I am junk, and so are you");
git.add().addFilepattern(junkFile2.getName()).call();
RevCommit commit2 = git.commit().setMessage("updating junk file").call();
//make sure develop doesn't have our commits yet
assertFalse(GitHelper.isMergedInto(git, commit, flow.getDevelopBranchName()));
assertFalse(GitHelper.isMergedInto(git, commit2, flow.getDevelopBranchName()));
//try to finish
flow.featureFinish("my-feature").setSquash(true).call();
//we should be on develop branch
assertEquals(flow.getDevelopBranchName(), git.getRepository().getBranch());
//feature branch should be gone
Ref ref2check = git.getRepository().getRef(flow.getFeatureBranchPrefix() + "my-feature");
assertNull(ref2check);
//the develop branch should NOT have both of our commits now
assertFalse(GitHelper.isMergedInto(git, commit, flow.getDevelopBranchName()));
assertFalse(GitHelper.isMergedInto(git, commit2, flow.getDevelopBranchName()));
//we should have the feature files
File developJunk = new File(git.getRepository().getWorkTree(), "junk.txt");
File developJunk2 = new File(git.getRepository().getWorkTree(), "junk2.txt");
assertTrue(developJunk.exists());