-
Notifications
You must be signed in to change notification settings - Fork 892
/
Copy pathCommitRewriteInfo.cs
102 lines (94 loc) · 4.47 KB
/
CommitRewriteInfo.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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>
/// <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)
{
return From(commit, author, null, null);
}
/// <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="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, string message)
{
return From(commit, null, null, 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>
/// <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, Signature committer)
{
return From(commit, author, committer, null);
}
/// <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,
Signature committer,
string message)
{
var cri = From(commit);
cri.Author = author ?? cri.Author;
cri.Committer = committer ?? cri.Committer;
cri.Message = message ?? cri.Message;
return cri;
}
}
}