Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CommitRewriteInfo.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e0a5caaa5e295b62f11b8ffaa1e0fa31ad302bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
namespace LibGit2Sharp
{
    /// <summary>
    /// Commit metadata when rewriting history
    /// </summary>
    public sealed class CommitRewriteInfo
    {
        /// <summary>
        /// The author to be used for the new commit
        /// </summary>
        public Signature Author { get; set; }

        /// <summary>
        /// The committer to be used for the new commit
        /// </summary>
        public Signature Committer { get; set; }

        /// <summary>
        /// The message to be used for the new commit
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in
        /// </summary>
        /// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
        /// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the <paramref name="commit"/>.</returns>
        public static CommitRewriteInfo From(Commit commit)
        {
            return new CommitRewriteInfo
                {
                    Author = commit.Author,
                    Committer = commit.Committer,
                    Message = commit.Message
                };
        }

        /// <summary>
        /// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
        /// optionally overriding some of its properties
        /// </summary>
        /// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
        /// <param name="author">Optional override for the author</param>
        /// <param name="committer">Optional override for the committer</param>
        /// <param name="message">Optional override for the message</param>
        /// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
        /// <paramref name="commit"/> with the optional parameters replaced..</returns>
        public static CommitRewriteInfo From(Commit commit,
                                             Signature author = null,
                                             Signature committer = null,
                                             string message = null)
        {
            var cri = From(commit);
            cri.Author = author ?? cri.Author;
            cri.Committer = committer ?? cri.Committer;
            cri.Message = message ?? cri.Message;

            return cri;
        }
    }
}