Package org.eclipse.jgit.api

Examples of org.eclipse.jgit.api.Git


    }

    @Test(expected = BranchOutOfDateException.class)
    public void finishHotfixMasterBehindRemoteWithFetch() throws Exception
    {
        Git git = null;
        Git remoteGit = null;
        remoteGit = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());

        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.hotfixStart("1.0").call();

        //do a commit to the remote develop branch
        remoteGit.checkout().setName(flow.getMasterBranchName());
        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.hotfixFinish("1.0").setFetch(true).call();

    }
View Full Code Here


    }

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

        String masterBranchName = flow.getMasterBranchName();

        RevCommit oldMasterHead = GitHelper.getLatestCommit(git, masterBranchName );

        flow.hotfixStart("1.0").call();

        // Make sure we move away from master on a hotfix branch
        // This is important to validate JGITFFLOW-14

        //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();
        git.commit().setMessage("committing junk file").call();

        flow.hotfixFinish("1.0").setNoTag( false ).call();

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

        // There should be a tag reference
        Ref hotfixTagRef = git.getRepository( ).getTags( ).get( flow.getVersionTagPrefix( ) + "1.0" );

        assertNotNull( hotfixTagRef );

        RevTag hotfixTag = new RevWalk( git.getRepository( ) ).parseTag( hotfixTagRef.getObjectId( ) );

        assertNotNull( hotfixTag );

        RevCommit newMasterHead = GitHelper.getLatestCommit(git, masterBranchName );
View Full Code Here

public class FeaturePublishTest extends BaseGitFlowTest
{
    @Test
    public void simplePublish() throws Exception
    {
        Git git = null;
        Git remoteGit = null;
        remoteGit = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());

        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();

        //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();

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

        assertTrue(GitHelper.isMergedInto(remoteGit, commit, flow.getFeatureBranchPrefix() + "my-feature"));
        remoteGit.checkout().setName(flow.getFeatureBranchPrefix() + "my-feature").call();
       
        File remoteJunk = new File(remoteGit.getRepository().getWorkTree(),junkFile.getName());
        assertTrue(remoteJunk.exists());

        assertEquals(flow.getFeatureBranchPrefix() + "my-feature", git.getRepository().getBranch());
       
    }
View Full Code Here

    }

    @Test(expected = DirtyWorkingTreeException.class)
    public void publishFeatureWithUnStagedFile() throws Exception
    {
        Git git = null;
        Git remoteGit = null;
        remoteGit = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());

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

    }

    @Test(expected = DirtyWorkingTreeException.class)
    public void publishFeatureUnCommittedFile() throws Exception
    {
        Git git = null;
        Git remoteGit = null;
        remoteGit = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());

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

    }

    @Test(expected = LocalBranchMissingException.class)
    public void publishFeatureWithMissingLocalBranch() throws Exception
    {
        Git git = null;
        Git remoteGit = null;
        remoteGit = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());

        git = Git.cloneRepository().setDirectory(newDir()).setURI("file://" + remoteGit.getRepository().getWorkTree().getPath()).call();

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

        //create a new commit
View Full Code Here

    }

    @Test(expected = RemoteBranchExistsException.class)
    public void publishFeatureWithExistingRemoteBranch() throws Exception
    {
        Git git = null;
        Git remoteGit = null;
        remoteGit = RepoUtil.createRepositoryWithMasterAndDevelop(newDir());

        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();

        //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();
        git.commit().setMessage("committing junk file").call();

        //manually add the feature branch to remote
        remoteGit.branchCreate().setName(flow.getFeatureBranchPrefix() + "my-feature").call();
       
        flow.featurePublish("my-feature").call();
    }
View Full Code Here

public class HotfixFinishTest extends BaseGitFlowTest
{
    @Test
    public void finishHotfix() throws Exception
    {
        Git git = RepoUtil.createRepositoryWithMaster(newDir());
        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

        flow.hotfixStart("1.0").call();

        assertEquals(flow.getHotfixBranchPrefix() + "1.0", git.getRepository().getBranch());

        flow.hotfixFinish("1.0").call();

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

        //release branch should be gone
        Ref ref2check = git.getRepository().getRef(flow.getHotfixBranchPrefix() + "1.0");
        assertNull(ref2check);

    }
View Full Code Here

    public void finishHotfixMultipleTimesWithCommits() throws Exception
    {
        String hfOneLabel = "1.0.1";
        String hfTwoLabel = "1.0.2";
       
        Git git = RepoUtil.createRepositoryWithMaster(newDir());
        JGitFlowInitCommand initCommand = new JGitFlowInitCommand();
        JGitFlow flow = initCommand.setDirectory(git.getRepository().getWorkTree()).call();

        flow.hotfixStart(hfOneLabel).call();

        assertEquals(flow.getHotfixBranchPrefix() + hfOneLabel, git.getRepository().getBranch());

        File versionFile = new File(git.getRepository().getWorkTree(), "version.txt");
        FileUtils.writeStringToFile(versionFile, hfOneLabel);
        git.add().addFilepattern(".").call();
        git.commit().setMessage("commiting version 1").call();
       
        flow.hotfixFinish(hfOneLabel).call();

        //we should be on develop branch
        assertEquals(flow.getDevelopBranchName(), git.getRepository().getBranch());
        FileUtils.writeStringToFile(versionFile, "develop");
        git.add().addFilepattern(".").call();
        git.commit().setMessage("commiting develop").call();
       
        flow.hotfixStart(hfTwoLabel).call();

        assertEquals(flow.getHotfixBranchPrefix() + hfTwoLabel, git.getRepository().getBranch());

        FileUtils.writeStringToFile(versionFile, hfTwoLabel);
        git.add().addFilepattern(".").call();
        git.commit().setMessage("commiting version 2").call();

        flow.hotfixFinish(hfTwoLabel).call();

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

    }
View Full Code Here

    }

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

        flow.hotfixStart("1.0").call();

        //create a new file
        File junkFile = new File(git.getRepository().getWorkTree(), "junk.txt");
        FileUtils.writeStringToFile(junkFile, "I am junk");

        //try to finish
        flow.hotfixFinish("1.0").call();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.Git

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.