8000 Rename GitSortOptions into CommitSortStrategies · freevoid/libgit2sharp@6a257ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a257ed

Browse files
committed
Rename GitSortOptions into CommitSortStrategies
1 parent 7d9baab commit 6a257ed

11 files changed

+73
-17
lines changed

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased()
7777
{
7878
using (var repo = new Repository(BareTestRepoPath))
7979
{
80-
Assert.Equal(GitSortOptions.Time, repo.Commits.SortedBy);
80+
Assert.Equal(CommitSortStrategies.Time, repo.Commits.SortedBy);
8181
}
8282
}
8383

@@ -140,7 +140,11 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
140140
int count = 0;
141141
using (var repo = new Repository(BareTestRepoPath))
142142
{
143-
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time | GitSortOptions.Reverse }))
143+
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
144+
{
145+
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
146+
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
147+
}))
144148
{
145149
Assert.NotNull(commit);
146150
Assert.True(commit.Sha.StartsWith(reversedShas[count]));
@@ -155,7 +159,11 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
155159
{
156160
using (var repo = new Repository(BareTestRepoPath))
157161
{
158-
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time | GitSortOptions.Reverse }).ToList();
162+
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter
163+
{
164+
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
165+
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
166+
}).ToList();
159167
foreach (Commit commit in commits)
160168
{
161169
Assert.NotNull(commit);
@@ -183,7 +191,11 @@ public void CanEnumerateCommitsWithTimeSorting()
183191
int count = 0;
184192
using (var repo = new Repository(BareTestRepoPath))
185193
{
186-
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time }))
194+
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
195+
{
196+
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
197+
SortBy = CommitSortStrategies.Time
198+
}))
187199
{
188200
Assert.NotNull(commit);
189201
Assert.True(commit.Sha.StartsWith(expectedShas[count]));
@@ -198,7 +210,11 @@ public void CanEnumerateCommitsWithTopoSorting()
198210
{
199211
using (var repo = new Repository(BareTestRepoPath))
200212
{
201-
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Topological }).ToList();
213+
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter
214+
{
215+
Since = "a4a7dce85cf63874e984719f4fdd239f5145052f",
216+
SortBy = CommitSortStrategies.Topological
217+
}).ToList();
202218
foreach (Commit commit in commits)
203219
{
204220
Assert.NotNull(commit);

LibGit2Sharp/CommitFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class CommitFilter
1414
/// </summary>
1515
public CommitFilter()
1616
{
17-
SortBy = GitSortOptions.Time;
17+
SortBy = CommitSortStrategies.Time;
1818
Since = "HEAD";
1919
}
2020

@@ -24,7 +24,7 @@ public CommitFilter()
2424
/// By default, the commits are shown in reverse chronological order.
2525
/// </para>
2626
/// </summary>
27-
public GitSortOptions SortBy { get; set; }
27+
public CommitSortStrategies SortBy { get; set; }
2828

2929
/// <summary>
3030
/// A pointer to a commit object or a list of pointers to consider as starting points.

LibGit2Sharp/CommitLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal CommitLog(Repository repo, CommitFilter queryFilter)
4646
/// <summary>
4747
/// Gets the current sorting strategy applied when enumerating the log
4848
/// </summary>
49-
public virtual GitSortOptions SortedBy
49+
public virtual CommitSortStrategies SortedBy
5050
{
5151
get { return queryFilter.SortBy; }
5252
}
@@ -248,7 +248,7 @@ private void Hide(IList<object> identifier)
248248
InternalHidePush(identifier, Proxy.git_revwalk_hide);
249249
}
250250

251-
private void Sort(GitSortOptions options)
251+
private void Sort(CommitSortStrategies options)
252252
{
253253
Proxy.git_revwalk_sorting(handle, options);
254254
}

LibGit2Sharp/CommitSortStrategies.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
3+
namespace LibGit2Sharp
4+
{
5+
/// <summary>
6+
/// Determines the sorting strategy when iterating through the commits of the repository
7+
/// </summary>
8+
[Flags]
9+
public enum CommitSortStrategies
10+
{
11+
/// <summary>
12+
/// Sort the commits in no particular ordering;
13+
/// this sorting is arbitrary, implementation-specific
14+
/// and subject to change at any time.
15+
/// </summary>
16+
None = 0,
17+
18+
/// <summary>
19+
/// Sort the commits in topological order
20+
/// (parents before children); this sorting mode
21+
/// can be combined with time sorting.
22+
/// </summary>
23+
Topological = (1 << 0),
24+
25+
/// <summary>
26+
/// Sort the commits by commit time;
27+
/// this sorting mode can be combined with
28+
/// topological sorting.
29+
/// </summary>
30+
Time = (1 << 1),
31+
32+
/// <summary>
33+
/// Iterate through the commits in reverse
34+
/// order; this sorting mode can be combined with
35+
/// any of the above.
36+
/// </summary>
37+
Reverse = (1 << 2)
38+
}
39+
}

LibGit2Sharp/Core/HistoryRewriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public void Execute()
4343
// Find out which refs lead to at least one the commits
4444
var refsToRewrite = repo.Refs.ReachableFrom(targetedCommits).ToList();
4545

46-
var filter = new CommitFilter()
46+
var filter = new CommitFilter
4747
{
4848
Since = refsToRewrite,
49-
SortBy = GitSortOptions.Reverse | GitSortOptions.Topological
49+
SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological
5050
};
5151

5252
var commits = repo.Commits.QueryBy(filter);

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ internal static extern int git_revparse_single(
983983
internal static extern void git_revwalk_reset(RevWalkerSafeHandle walker);
984984

985985
[DllImport(libgit2)]
986-
internal static extern void git_revwalk_sorting(RevWalkerSafeHandle walk, GitSortOptions sort);
986+
internal static extern void git_revwalk_sorting(RevWalkerSafeHandle walk, CommitSortStrategies sort);
987987

988988
[DllImport(libgit2)]
989989
internal static extern void git_signature_free(IntPtr signature);

LibGit2Sharp/Core/Proxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ public static void git_revwalk_reset(RevWalkerSafeHandle walker)
18501850
NativeMethods.git_revwalk_reset(walker);
18511851
}
18521852

1853-
public static void git_revwalk_sorting(RevWalkerSafeHandle walker, GitSortOptions options)
1853+
public static void git_revwalk_sorting(RevWalkerSafeHandle walker, CommitSortStrategies options)
18541854
{
18551855
NativeMethods.git_revwalk_sorting(walker, options);
18561856
}

LibGit2Sharp/Filter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal CommitFilter ToCommitFilter()
5151
var cf = new CommitFilter
5252
{
5353
Since = Since,
54-
SortBy = SortBy,
54+
SortBy = (CommitSortStrategies) SortBy,
5555
Until = Until
5656
};
5757

LibGit2Sharp/GitSortOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace LibGit2Sharp
66
/// Determines the sorting strategy when iterating through the content of the repository
77
/// </summary>
88
[Flags]
9+
[Obsolete("This type will be removed in the next release.")]
910
public enum GitSortOptions
1011
{
1112
/// <summary>

LibGit2Sharp/ICommitLog.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32

43
namespace LibGit2Sharp
54
{
@@ -11,6 +10,6 @@ public interface ICommitLog : IEnumerable<Commit>
1110
/// <summary>
1211
/// Gets the current sorting strategy applied when enumerating the log.
1312
/// </summary>
14-
GitSortOptions SortedBy { get; }
13+
CommitSortStrategies SortedBy { get; }
1514
}
1615
}

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="CheckoutNotificationOptions.cs" />
7070
<Compile Include="CheckoutOptions.cs" />
7171
<Compile Include="CommitFilter.cs" />
72+
<Compile Include="CommitSortStrategies.cs" />
7273
<Compile Include="CompareOptions.cs" />
7374
<Compile Include="Core\GitRepositoryInitOptions.cs" />
7475
<Compile Include="Core\HistoryRewriter.cs" />

0 commit comments

Comments
 (0)
0