示例#1
0
    /// <summary>
    /// Creates a new commit from the current state of the staging area.
    /// Appends the commit to the current branch and clears the staging area.
    /// Clears the preview of the staging area.
    ///
    /// Additional parameter for forcing commits through the player's enabled version control mechanics
    /// such as for oneShot doors.
    /// </summary>
    public ICommit Commit(string message, bool forced)
    {
        if (!EnabledVersionControls.Instance().CanCommit&& !forced)
        {
            Debug.Log("Can't Commit; not enabled yet");
            return(null);
        }
        if (isDetached)
        {
            throw new InvalidOperationException("Cannot commit in detached HEAD state");
        }

        CommitBuilder builder = new CommitBuilder();

        builder.SetMessage(message);
        builder.SetParent(activeCommit);
        foreach (VersionController controller in trackedObjects)
        {
            IVersion controllerVersion;
            if (stagingArea.Contains(controller))
            {
                // increment commit count
                controllerVersion = controller.GenerateVersion();
            }
            else
            {
                controllerVersion = controller.GetVersion();
            }
            builder.AddObject(controller, controllerVersion);
        }
        ICommit commit = builder.Build();

        activeCommit = commit;
        foreach (VersionController stagedController in stagingArea)
        {
            stagedController.HideStagedState();
        }
        if (activeBranch != null)
        {
            activeBranch.UpdateTip(activeCommit);
        }
        stagingArea.Clear();

        if (commitTrigger != null)
        {
            commitTrigger.Trigger();
        }

        UIController.Instance().UpdateOverlay();

        return(commit);
    }
示例#2
0
    protected override void Awake()
    {
        base.Awake();

        //Construct Initial Commit
        CommitBuilder cb = new CommitBuilder();

        cb.SetMessage("Initial Commit");
        ICommit initialCommit = cb.Build();

        activeCommit = initialCommit;
        activeBranch.UpdateTip(initialCommit);
    }