Examples of JGitFlow


Examples of com.atlassian.jgitflow.core.JGitFlow

        File nested2 = new File(nested1,"nested2");
       
        nested2.mkdirs();
       
        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(nested2).call();

        flow.git().checkout().setName("develop").call();
        assertEquals(flow.getDevelopBranchName(), flow.git().getRepository().getBranch());

        File gitDir = git.getRepository().getDirectory();
        File gitConfig = new File(gitDir, "config");

        assertTrue(gitConfig.exists());

        String configText = new String(IO.readFully(gitConfig));

        assertTrue(configText.contains("[gitflow \"branch\"]"));
        assertTrue(configText.contains("[gitflow \"prefix\"]"));

        assertEquals("master", flow.getMasterBranchName());
        assertEquals("develop", flow.getDevelopBranchName());
        assertEquals("feature/", flow.getFeatureBranchPrefix());
        assertEquals("release/", flow.getReleaseBranchPrefix());
        assertEquals("hotfix/", flow.getHotfixBranchPrefix());
        assertEquals("support/", flow.getSupportBranchPrefix());
        assertEquals("", flow.getVersionTagPrefix());

    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test
    public void finishFeature() throws Exception
    {
        Git git = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());
        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

        flow.featureStart("my-feature").call();

        //just in case
        assertEquals(flow.getFeatureBranchPrefix() + "my-feature", git.getRepository().getBranch());
       
        flow.featureFinish("my-feature").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);

    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test(expected = DirtyWorkingTreeException.class)
    public void finishFeatureWithUnStagedFile() 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 file
        File junkFile = new File(git.getRepository().getWorkTree(), "junk.txt");
        FileUtils.writeStringToFile(junkFile, "I am junk");
       
        //try to finish
        flow.featureFinish("my-feature").call();
    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test(expected = DirtyWorkingTreeException.class)
    public void finishFeatureUnCommittedFile() 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 file and add it to the index
        File junkFile = new File(git.getRepository().getWorkTree(), "junk.txt");
        FileUtils.writeStringToFile(junkFile, "I am junk");
        git.add().addFilepattern(junkFile.getName()).call();

        //try to finish
        flow.featureFinish("my-feature").call();
    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test
    public void finishFeatureWithNewCommit() 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();
       
        //make sure develop doesn't report our commit yet
        assertFalse(GitHelper.isMergedInto(git, commit, flow.getDevelopBranchName()));
       
        //try to finish
        flow.featureFinish("my-feature").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 have our commit
        assertTrue(GitHelper.isMergedInto(git, commit, flow.getDevelopBranchName()));
    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test
    public void finishFeatureKeepBranch() throws Exception
    {
        Git git = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());
        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

        flow.featureStart("my-feature").call();

        //just in case
        assertEquals(flow.getFeatureBranchPrefix() + "my-feature", git.getRepository().getBranch());

        flow.featureFinish("my-feature").setKeepBranch(true).call();

        //we should be on develop branch
        assertEquals(flow.getDevelopBranchName(), git.getRepository().getBranch());

        //feature branch should still exist
        Ref ref2check = git.getRepository().getRef(flow.getFeatureBranchPrefix() + "my-feature");
        assertNotNull(ref2check);
    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test
    public void finishFeatureWithMultipleCommits() 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").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 have both of our commits now
        assertTrue(GitHelper.isMergedInto(git, commit, flow.getDevelopBranchName()));
        assertTrue(GitHelper.isMergedInto(git, commit2, flow.getDevelopBranchName()));
    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @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());
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

        remoteGit = RepoUtil.createRepositoryWithBranches(newDir(), "develop", "feature/my-feature");
       
        git = Git.cloneRepository().setDirectory(newDir()).setURI("file://" + remoteGit.getRepository().getWorkTree().getPath()).call();

        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

        flow.featureStart("my-feature").call();

        //do a commit to the remote feature branch
        remoteGit.checkout().setName(flow.getFeatureBranchPrefix() + "my-feature");
        File junkFile = new File(remoteGit.getRepository().getWorkTree(), "junk.txt");
        FileUtils.writeStringToFile(junkFile, "I am junk");
        remoteGit.add().addFilepattern(junkFile.getName()).call();
        remoteGit.commit().setMessage("adding junk file").call();

        flow.featureFinish("my-feature").setFetchDevelop(true).call();

    }
View Full Code Here

Examples of com.atlassian.jgitflow.core.JGitFlow

    @Test(expected = MergeConflictsNotResolvedException.class)
    public void finishFeatureMergeConflict() throws Exception
    {
        Git git = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());
        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

        flow.featureStart("my-feature").call();
       
        //go back to develop and do a commit
        git.checkout().setName(flow.getDevelopBranchName()).call();
        File junkFile = new File(git.getRepository().getWorkTree(), "junk.txt");
        FileUtils.writeStringToFile(junkFile, "A");
        git.add().addFilepattern(junkFile.getName()).call();
        git.commit().setMessage("committing junk file").call();

        //commit the same file in feature to create a conflict
        git.checkout().setName(flow.getFeatureBranchPrefix() + "my-feature").call();
        FileUtils.writeStringToFile(junkFile, "B");
        git.add().addFilepattern(junkFile.getName()).call();
        git.commit().setMessage("committing junk file").call();

        //try to finish
        try
        {
            flow.featureFinish("my-feature").setKeepBranch(true).call();
        }
        catch (Exception e)
        {
            File gitFlowDir = new File(git.getRepository().getDirectory(), JGitFlowConstants.GITFLOW_DIR);
            File mergeBase = new File(gitFlowDir, JGitFlowConstants.MERGE_BASE);
            assertTrue(mergeBase.exists());
            assertEquals(flow.getDevelopBranchName(), FileHelper.readFirstLine(mergeBase));
           
            throw e;
        }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.