示例#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
        static void Main(string[] args)
        {
            do
            {
                Console.WriteLine("*** GitHub Manager ***");

                string user       = GetUserFromConsole();
                string repository = GetRepositoryFromConsole();

                var    api    = new CommitApi();
                string result = api.GetResponse(user, repository);

                try
                {
                    JArray resultArray = JArray.Parse(result);

                    foreach (JObject commit in resultArray)
                    {
                        IBuilder builder  = new CommitBuilder(commit);
                        Director director = new Director(builder);

                        var    commitJson        = builder.Build();
                        string commitConsoleLine = GetOneCommitLine(repository, commitJson);

                        Commit commitToDatabase = new Commit
                        {
                            User       = user,
                            Repository = repository,
                            Sha        = commitJson["sha"],
                            Message    = commitJson["message"],
                            Committer  = commitJson["committerName"]
                        };

                        try
                        {
                            CommitModel model = new CommitModel();
                            model.SaveToDatabase(commitToDatabase);
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Error 002: Database write error.");
                        }

                        Console.WriteLine(commitConsoleLine);
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Error 001: Bad request. Try Again.");
                }
            }while (true);
        }
示例#3
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);
    }