Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert CommitCollection.StartingAt() overloads as extension methods
- Loading branch information
Showing
3 changed files
with
62 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using LibGit2Sharp.Core; | ||
|
||
namespace LibGit2Sharp | ||
{ | ||
public static class CommitCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Starts enumerating the <paramref name="commitCollection"/> at the specified branch. | ||
/// </summary> | ||
/// <param name="commitCollection">The commit collection to enumerate.</param> | ||
/// <param name = "branch">The branch.</param> | ||
/// <returns></returns> | ||
public static CommitCollection StartingAt(this CommitCollection commitCollection, Branch branch) | ||
{ | ||
Ensure.ArgumentNotNull(branch, "branch"); | ||
|
||
return commitCollection.StartingAt(branch.Tip.Sha); | ||
} | ||
|
||
/// <summary> | ||
/// Starts enumerating the <paramref name="commitCollection"/> at the specified reference. | ||
/// </summary> | ||
/// <param name="commitCollection">The commit collection to enumerate.</param> | ||
/// <param name = "reference">The reference.</param> | ||
/// <returns></returns> | ||
public static CommitCollection StartingAt(this CommitCollection commitCollection, Reference reference) | ||
{ | ||
Ensure.ArgumentNotNull(reference, "reference"); | ||
|
||
return commitCollection.StartingAt(reference.ResolveToDirectReference().Target.Sha); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters