Esempio n. 1
0
        public void Create(string message)
        {
            //Loads the files in the working directory
            Version working = directory.GetWorkingVersion();
            //Aggregates the files from all commits up to HEAD
            Head   head         = directory.GetHead();
            Commit parentCommit = head.GetTarget();
            AggregatedChangelog parentAggregate = parentCommit.AggregateChangelog();
            Version             parent          = directory.AggregateVersion(parentAggregate);
            //Creates the data fields for commit
            Changelog      diffChangelog = parent.GetChangelog(working);
            Version        diffVersion   = working.GetChangelogVersion(diffChangelog);
            CommitMetadata metadata      = new CommitMetadata(message);
            //Creates the commit
            Commit newCommit = new Commit(parentCommit, diffChangelog, diffVersion, metadata);

            //Adds the data fields to the file directory
            directory.CreateVersion(diffVersion);
            directory.CreateChangelog(diffChangelog);
            directory.CreateCommit(newCommit);
            //Update the position of the HEAD
            directory.UpdateHead(head, newCommit);
        }