Beispiel #1
0
    /// <summary>
    /// Checks out the commit specified by the given commit ID on the specified branch
    /// </summary>
    public void Checkout(IBranch branch, Guid commitId)
    {
        ICommit commit = branch.GetTip();

        while (!commit.GetId().Equals(commitId))
        {
            commit = commit.GetParent();
        }
        Checkout(branch, commit);
    }
Beispiel #2
0
    public IEnumerator shouldBeAbleToCreateNewBranchWhenInDetachedHeadAndThenCommit()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionableBox();
        VersionController otherTestController = factory.createVersionableBox();

        GameObject testObject      = testController.GetActiveVersion();
        GameObject otherTestObject = otherTestController.GetActiveVersion();

        testObject.transform.position      = new Vector2(0.0f, 0.0f);
        otherTestObject.transform.position = new Vector2(3.0f, 0.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Add(otherTestController);

        ICommit firstCommit   = VersionManager.Instance().Commit("Create two boxes");
        Guid    firstCommitId = firstCommit.GetId();

        yield return(null);

        testObject.transform.position      = new Vector2(1.0f, 0.0f);
        otherTestObject.transform.position = new Vector2(4.0f, 1.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Add(otherTestController);

        VersionManager.Instance().Commit("Move boxes");

        yield return(null);

        VersionManager.Instance().Checkout("master", firstCommitId);

        IBranch newBranch = VersionManager.Instance().CreateBranch("refactor");

        VersionManager.Instance().Checkout(newBranch);

        Assert.AreEqual(newBranch.GetTip().GetId(), VersionManager.Instance().GetActiveBranch().GetTip().GetId());
        Assert.AreEqual(newBranch.GetTip().GetId(), VersionManager.Instance().GetActiveCommit().GetId());

        testObject.transform.position = new Vector2(-1.0f, 0.0f);

        VersionManager.Instance().Add(testController);
        ICommit commit = VersionManager.Instance().Commit("Move a box to the left");

        Assert.AreEqual(newBranch.GetTip().GetId(), commit.GetId());
        Assert.True(commit.ObjectIsTrackedInThisCommit(testController));
        Assert.True(commit.ObjectIsTrackedInThisCommit(otherTestController));
    }
Beispiel #3
0
    public IEnumerator shouldNotBeAbleToCommitWhenInDetachedHeadState()
    {
        VersionableObjectFactory factory = new VersionableObjectFactory();

        VersionController testController      = factory.createVersionableBox();
        VersionController otherTestController = factory.createVersionableBox();

        GameObject testObject      = testController.GetActiveVersion();
        GameObject otherTestObject = otherTestController.GetActiveVersion();

        testObject.transform.position      = new Vector2(0.0f, 0.0f);
        otherTestObject.transform.position = new Vector2(3.0f, 0.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Add(otherTestController);

        ICommit firstCommit   = VersionManager.Instance().Commit("Create two boxes");
        Guid    firstCommitId = firstCommit.GetId();

        yield return(null);

        testObject.transform.position      = new Vector2(1.0f, 0.0f);
        otherTestObject.transform.position = new Vector2(4.0f, 1.0f);

        VersionManager.Instance().Add(testController);
        VersionManager.Instance().Add(otherTestController);

        VersionManager.Instance().Commit("Move boxes");

        yield return(null);

        VersionManager.Instance().Checkout("master", firstCommitId);

        testObject.transform.position = new Vector2(3.0f, 3.0f);

        VersionManager.Instance().Add(testController);

        ICommit commit = null;

        try {
            commit = VersionManager.Instance().Commit("Move the box");
            Assert.Fail();
        } catch (InvalidOperationException ioe) {
            Assert.AreEqual(ioe.Message, "Cannot commit in detached HEAD state");
            Assert.IsNull(commit);
            Assert.AreEqual(VersionManager.Instance().GetActiveCommit(), firstCommit);
        }
    }