Exemple #1
0
        private Commit BuildCommit(Commit oldCommit, CommitBuilder commitBuilder, IEnumerable <Commit> parents, Tree tree)
        {
            Signature author = oldCommit.Author;

            if (commitBuilder.CommitAuthor != null)
            {
                author = commitBuilder.CommitAuthor;
            }
            Signature committer = oldCommit.Committer;

            if (commitBuilder.CommitCommitter != null)
            {
                committer = commitBuilder.CommitCommitter;
            }
            string message = oldCommit.Message;

            if (!string.IsNullOrEmpty(commitBuilder.CommitMessage))
            {
                message = commitBuilder.CommitMessage;
            }
            return(_repository.ObjectDatabase.CreateCommit(author, committer, message, tree, parents, false));
        }
Exemple #2
0
        private Commit ApplyCommit(Commit commit)
        {
            List <Commit> newParents = new List <Commit>();

            foreach (Commit commitParent in commit.Parents)
            {
                newParents.Add(ApplyCommit(commitParent));
            }
            if (_appliedCommits.ContainsKey(commit.Sha))
            {
                return(_appliedCommits[commit.Sha]);
            }
            CommitBuilder commitBuilder = new CommitBuilder();

            CommitApplyConfig config = new CommitApplyConfig(commit, newParents, _repository.Index, commitBuilder, _repository);

            config.Index.Replace(commit);
            _commitApplier.Apply(config);
            Tree   tree      = _repository.Index.WriteToTree();
            Commit newCommit = BuildCommit(commit, commitBuilder, newParents, tree);

            _appliedCommits.Add(commit.Sha, newCommit);
            return(newCommit);
        }