Skip to content

Remove FollowFilter for add an override of QueryBy #1310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions LibGit2Sharp.Tests/FileHistoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void CanFollowBranches(string specificRepoPath)

// Test --date-order.
var timeHistory = repo.Commits.QueryBy(path,
new FollowFilter { SortBy = CommitSortStrategies.Time });
new CommitFilter { SortBy = CommitSortStrategies.Time });
var timeCommits = new List<Commit>
{
master10, // master
Expand All @@ -117,7 +117,7 @@ public void CanFollowBranches(string specificRepoPath)

// Test --topo-order.
var topoHistory = repo.Commits.QueryBy(path,
new FollowFilter { SortBy = CommitSortStrategies.Topological });
new CommitFilter { SortBy = CommitSortStrategies.Topological });
var topoCommits = new List<Commit>
{
master10, // master
Expand Down Expand Up @@ -255,33 +255,33 @@ public void UnsupportedSortStrategyThrows()
MakeAndCommitChange(repo, repoPath, path, "Hello World");

Assert.Throws<ArgumentException>(() =>
repo.Commits.QueryBy(path, new FollowFilter
repo.Commits.QueryBy(path, new CommitFilter
{
SortBy = CommitSortStrategies.None
}));

Assert.Throws<ArgumentException>(() =>
repo.Commits.QueryBy(path, new FollowFilter
repo.Commits.QueryBy(path, new CommitFilter
{
SortBy = CommitSortStrategies.Reverse
}));

Assert.Throws<ArgumentException>(() =>
repo.Commits.QueryBy(path, new FollowFilter
repo.Commits.QueryBy(path, new CommitFilter
{
SortBy = CommitSortStrategies.Reverse |
CommitSortStrategies.Topological
}));

Assert.Throws<ArgumentException>(() =>
repo.Commits.QueryBy(path, new FollowFilter
repo.Commits.QueryBy(path, new CommitFilter
{
SortBy = CommitSortStrategies.Reverse |
CommitSortStrategies.Time
}));

Assert.Throws<ArgumentException>(() =>
repo.Commits.QueryBy(path, new FollowFilter
repo.Commits.QueryBy(path, new CommitFilter
{
SortBy = CommitSortStrategies.Reverse |
CommitSortStrategies.Topological |
Expand Down
17 changes: 16 additions & 1 deletion LibGit2Sharp/CommitLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,27 @@ public IEnumerable<LogEntry> QueryBy(string path)
/// <param name="path">The file's path.</param>
/// <param name="filter">The options used to control which commits will be returned.</param>
/// <returns>A list of file history entries, ready to be enumerated.</returns>
[Obsolete("This method is deprecated. Please use the overload which take LibGit2Sharp.CommitFilter")]
public IEnumerable<LogEntry> QueryBy(string path, FollowFilter filter)
{
Ensure.ArgumentNotNull(path, "path");
Ensure.ArgumentNotNull(filter, "filter");

return new FileHistory(repo, path, new CommitFilter { SortBy = filter.SortBy });
return QueryBy(path, new CommitFilter { SortBy = filter.SortBy });
}

/// <summary>
/// Returns the list of commits of the repository representing the history of a file beyond renames.
/// </summary>
/// <param name="path">The file's path.</param>
/// <param name="filter">The options used to control which commits will be returned.</param>
/// <returns>A list of file history entries, ready to be enumerated.</returns>
public IEnumerable<LogEntry> QueryBy(string path, CommitFilter filter)
{
Ensure.ArgumentNotNull(path, "path");
Ensure.ArgumentNotNull(filter, "filter");

return new FileHistory(repo, path, filter);
}

private class CommitEnumerator : IEnumerator<Commit>
Expand Down
1 change: 1 addition & 0 deletions LibGit2Sharp/FollowFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace LibGit2Sharp
/// The commits will be enumerated from the current HEAD of the repository.
/// </para>
/// </summary>
[Obsolete("This type is deprecated. Please use LibGit2Sharp.CommitFilter")]
public sealed class FollowFilter
{
private static readonly List<CommitSortStrategies> AllowedSortStrategies = new List<CommitSortStrategies>
Expand Down
10 changes: 10 additions & 0 deletions LibGit2Sharp/IQueryableCommitLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public interface IQueryableCommitLog : ICommitLog
/// <param name="path">The file's path.</param>
/// <param name="filter">The options used to control which commits will be returned.</param>
/// <returns>A list of file history entries, ready to be enumerated.</returns>
[Obsolete("This method is deprecated. Please use the overload which take LibGit2Sharp.CommitFilter")]
IEnumerable<LogEntry> QueryBy(string path, FollowFilter filter);

/// <summary>
/// Returns the list of commits of the repository representing the history of a file beyond renames.
/// </summary>
/// <param name="path">The file's path.</param>
/// <param name="filter">The options used to control which commits will be returned.</param>
/// <returns>A list of file history entries, ready to be enumerated.</returns>
IEnumerable<LogEntry> QueryBy(string path, CommitFilter filter);

}
}