Skip to content

Commit 7c05885

Browse files
committed
Move CommitRewriteInfo overloads to Extensions
1 parent 360d31c commit 7c05885

File tree

3 files changed

+72
-64
lines changed

3 files changed

+72
-64
lines changed

LibGit2Sharp/CommitRewriteInfo.cs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace LibGit2Sharp
33
/// <summary>
44
/// Commit metadata when rewriting history
55
/// </summary>
6-
public sealed class CommitRewriteInfo
6+
public sealed partial class CommitRewriteInfo
77
{
88
/// <summary>
99
/// The author to be used for the new commit
@@ -34,68 +34,5 @@ public static CommitRewriteInfo From(Commit commit)
3434
Message = commit.Message
3535
};
3636
}
37-
38-
/// <summary>
39-
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
40-
/// optionally overriding some of its properties
41-
/// </summary>
42-
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
43-
/// <param name="author">Optional override for the author</param>
44-
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
45-
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
46-
public static CommitRewriteInfo From(Commit commit, Signature author)
47-
{
48-
return From(commit, author, null, null);
49-
}
50-
51-
/// <summary>
52-
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
53-
/// optionally overriding some of its properties
54-
/// </summary>
55-
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
56-
/// <param name="message">Optional override for the message</param>
57-
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
58-
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
59-
public static CommitRewriteInfo From(Commit commit, string message)
60-
{
61-
return From(commit, null, null, message);
62-
}
63-
64-
/// <summary>
65-
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
66-
/// optionally overriding some of its properties
67-
/// </summary>
68-
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
69-
/// <param name="author">Optional override for the author</param>
70-
/// <param name="committer">Optional override for the committer</param>
71-
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
72-
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
73-
public static CommitRewriteInfo From(Commit commit, Signature author, Signature committer)
74-
{
75-
return From(commit, author, committer, null);
76-
}
77-
78-
/// <summary>
79-
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
80-
/// optionally overriding some of its properties
81-
/// </summary>
82-
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
83-
/// <param name="author">Optional override for the author</param>
84-
/// <param name="committer">Optional override for the committer</param>
85-
/// <param name="message">Optional override for the message</param>
86-
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
87-
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
88-
public static CommitRewriteInfo From(Commit commit,
89-
Signature author,
90-
Signature committer,
91-
string message)
92-
{
93-
var cri = From(commit);
94-
cri.Author = author ?? cri.Author;
95-
cri.Committer = committer ?? cri.Committer;
96-
cri.Message = message ?? cri.Message;
97-
98-
return cri;
99-
}
10037
}
10138
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
namespace LibGit2Sharp
2+
{
3+
/// <summary>
4+
/// Provides helper overloads to a <see cref="CommitRewriteInfo"/>.
5+
/// </summary>
6+
public sealed partial class CommitRewriteInfo
7+
{ /// <summary>
8+
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
9+
/// optionally overriding some of its properties
10+
/// </summary>
11+
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
12+
/// <param name="author">Optional override for the author</param>
13+
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
14+
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
15+
public static CommitRewriteInfo From(Commit commit, Signature author)
16+
{
17+
return From(commit, author, null, null);
18+
}
19+
20+
/// <summary>
21+
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
22+
/// optionally overriding some of its properties
23+
/// </summary>
24+
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
25+
/// <param name="message">Optional override for the message</param>
26+
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
27+
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
28+
public static CommitRewriteInfo From(Commit commit, string message)
29+
{
30+
return From(commit, null, null, message);
31+
}
32+
33+
/// <summary>
34+
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
35+
/// optionally overriding some of its properties
36+
/// </summary>
37+
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
38+
/// <param name="author">Optional override for the author</param>
39+
/// <param name="committer">Optional override for the committer</param>
40+
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
41+
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
42+
public static CommitRewriteInfo From(Commit commit, Signature author, Signature committer)
43+
{
44+
return From(commit, author, committer, null);
45+
}
46+
47+
/// <summary>
48+
/// Build a <see cref="CommitRewriteInfo"/> from the <see cref="Commit"/> passed in,
49+
/// optionally overriding some of its properties
50+
/// </summary>
51+
/// <param name="commit">The <see cref="Commit"/> whose information is to be copied</param>
52+
/// <param name="author">Optional override for the author</param>
53+
/// <param name="committer">Optional override for the committer</param>
54+
/// <param name="message">Optional override for the message</param>
55+
/// <returns>A new <see cref="CommitRewriteInfo"/> object that matches the info for the
56+
/// <paramref name="commit"/> with the optional parameters replaced..</returns>
57+
public static CommitRewriteInfo From(Commit commit,
58+
Signature author,
59+
Signature committer,
60+
string message)
61+
{
62+
var cri = From(commit);
63+
cri.Author = author ?? cri.Author;
64+
cri.Committer = committer ?? cri.Committer;
65+
cri.Message = message ?? cri.Message;
66+
67+
return cri;
68+
}
69+
}
70+
}

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<Compile Include="CloneOptions.cs" />
6868
<Compile Include="CommitFilter.cs" />
6969
<Compile Include="CommitOptions.cs" />
70+
<Compile Include="CommitRewriteInfoExtensions.cs" />
7071
<Compile Include="CommitSortStrategies.cs" />
7172
<Compile Include="CompareOptions.cs" />
7273
<Compile Include="Core\FileHistory.cs" />

0 commit comments

Comments
 (0)