Skip to content

Commit d62ae53

Browse files
yorahnulltoken
authored andcommitted
Make CommitLog mockable
1 parent 595a3ca commit d62ae53

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

LibGit2Sharp/CommitLog.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public class CommitLog : IQueryableCommitLog
1818
private IList<object> excludedIdentifier = new List<object>();
1919
private readonly GitSortOptions sortOptions;
2020

21+
/// <summary>
22+
/// Needed for mocking purposes.
23+
/// </summary>
24+
protected CommitLog()
25+
{ }
26+
2127
/// <summary>
2228
/// Initializes a new instance of the <see cref = "CommitLog" /> class.
2329
/// The commits will be enumerated according in reverse chronological order.
@@ -42,7 +48,7 @@ internal CommitLog(Repository repo, GitSortOptions sortingStrategy)
4248
/// <summary>
4349
/// Gets the current sorting strategy applied when enumerating the log
4450
/// </summary>
45-
public GitSortOptions SortedBy
51+
public virtual GitSortOptions SortedBy
4652
{
4753
get { return sortOptions; }
4854
}
@@ -53,7 +59,7 @@ public GitSortOptions SortedBy
5359
/// Returns an enumerator that iterates through the log.
5460
/// </summary>
5561
/// <returns>An <see cref = "IEnumerator{T}" /> object that can be used to iterate through the log.</returns>
56-
public IEnumerator<Commit> GetEnumerator()
62+
public virtual IEnumerator<Commit> GetEnumerator()
5763
{
5864
if ((repo.Info.IsEmpty) && includedIdentifier.Any(o => PointsAtTheHead(o.ToString()))) // TODO: ToString() == fragile
5965
{
@@ -79,7 +85,7 @@ IEnumerator IEnumerable.GetEnumerator()
7985
/// </summary>
8086
/// <param name = "filter">The options used to control which commits will be returned.</param>
8187
/// <returns>A list of commits, ready to be enumerated.</returns>
82-
public ICommitLog QueryBy(Filter filter)
88+
public virtual ICommitLog QueryBy(Filter filter)
8389
{
8490
Ensure.ArgumentNotNull(filter, "filter");
8591
Ensure.ArgumentNotNull(filter.Since, "filter.Since");
@@ -130,7 +136,7 @@ private static bool PointsAtTheHead(string shaOrRefName)
130136
/// <param name = "first">The first <see cref = "Commit"/>.</param>
131137
/// <param name = "second">The second <see cref = "Commit"/>.</param>
132138
/// <returns>The common ancestor or null if none found.</returns>
133-
public Commit FindCommonAncestor(Commit first, Commit second)
139+
public virtual Commit FindCommonAncestor(Commit first, Commit second)
134140
{
135141
Ensure.ArgumentNotNull(first, "first");
136142
Ensure.ArgumentNotNull(second, "second");
@@ -157,7 +163,7 @@ public Commit FindCommonAncestor(Commit first, Commit second)
157163
/// </summary>
158164
/// <param name = "commits">The <see cref = "Commit"/>s for which to find the common ancestor.</param>
159165
/// <returns>The common ancestor or null if none found.</returns>
160-
public Commit FindCommonAncestor(IEnumerable<Commit> commits)
166+
public virtual Commit FindCommonAncestor(IEnumerable<Commit> commits)
161167
{
162168
Ensure.ArgumentNotNull(commits, "commits");
163169
Commit ret = null;

0 commit comments

Comments
 (0)