8000 Rename CheckoutOptions into CheckoutModifiers · freevoid/libgit2sharp@219b0c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 219b0c5

Browse files
committed
Rename CheckoutOptions into CheckoutModifiers
1 parent d05b0da commit 219b0c5

File tree

9 files changed

+70
-47
lines changed

9 files changed

+70
-47
lines changed

LibGit2Sharp.Tests/CheckoutFixture.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges()
266266
Assert.Throws<MergeConflictException>(() => repo.Checkout(master.CanonicalName));
267267

268268
// Checkout with force option should succeed.
269-
repo.Checkout(master.CanonicalName, CheckoutOptions.Force, null, null);
269+
repo.Checkout(master.CanonicalName, CheckoutModifiers.Force, null, null);
270270

271271
// Assert that master branch is checked out.
272272
Assert.True(repo.Branches["master"].IsCurrentRepositoryHead);
@@ -339,7 +339,7 @@ public void CanCancelCheckoutThroughNotifyCallback()
339339
// Verify that we get called for the notify conflict cb
340340
string conflictPath = string.Empty;
341341
CheckoutNotificationOptions checkoutNotifications = new CheckoutNotificationOptions((path, flags) => { conflictPath = path; return false; }, CheckoutNotifyFlags.Conflict);
342-
Assert.Throws<UserCancelledException>(() => repo.Checkout("master", CheckoutOptions.None, null, checkoutNotifications));
342+
Assert.Throws<UserCancelledException>(() => repo.Checkout("master", CheckoutModifiers.None, null, checkoutNotifications));
343343
Assert.Equal(relativePath, conflictPath);
344344
}
345345
}
@@ -398,7 +398,7 @@ public void CheckingOutThroughBranchCallsCheckoutProgress()
398398
bool wasCalled = false;
399399

400400
Branch branch = repo.Branches[otherBranchName];
401-
branch.Checkout(CheckoutOptions.None, (path, completed, total) => wasCalled = true, null);
401+
branch.Checkout(CheckoutModifiers.None, (path, completed, total) => wasCalled = true, null);
402402

403403
Assert.True(wasCalled);
404404
}
@@ -414,7 +414,7 @@ public void CheckingOutThroughRepositoryCallsCheckoutProgress()
414414
PopulateBasicRepository(repo);
415415
bool wasCalled = false;
416416

417-
repo.Checkout(otherBranchName, CheckoutOptions.None, (path, completed, total) => wasCalled = true, null);
417+
repo.Checkout(otherBranchName, CheckoutModifiers.None, (path, completed, total) => wasCalled = true, null);
418418

419419
Assert.True(wasCalled);
420420
}
@@ -490,7 +490,7 @@ public void CheckingOutCallsCheckoutNotify(CheckoutNotifyFlags notifyFlags, stri
490490
(path, notificationType) => { wasCalled = true; actualNotificationPath = path; actualNotifyFlags = notificationType; return true; },
491491
notifyFlags);
492492

493-
Assert.Throws<MergeConflictException>(() => repo.Checkout("master", CheckoutOptions.None, null, checkoutNotifications));
493+
Assert.Throws<MergeConflictException>(() => repo.Checkout("master", CheckoutModifiers.None, null, checkoutNotifications));
494494

495495
Assert.True(wasCalled);
496496
Assert.Equal(expectedNotificationPath, actualNotificationPath);
@@ -538,7 +538,7 @@ public void ForceCheckoutRetainsUntrackedChanges()
538538
Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count());
539539
Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(fullPathFileB));
540540

541-
repo.Checkout(otherBranchName, CheckoutOptions.Force, null, null);
541+
repo.Checkout(otherBranchName, CheckoutModifiers.Force, null, null);
542542

543543
// Verify untracked entry still exists.
544544
Assert.Equal(1, repo.Index.RetrieveStatus().Untracked.Count());
@@ -641,7 +641,7 @@ public void ForceCheckoutRetainsIgnoredChanges()
641641

642642
Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath));
643643

644-
repo.Checkout(otherBranchName, CheckoutOptions.Force, null, null);
644+
repo.Checkout(otherBranchName, CheckoutModifiers.Force, null, null);
645645

646646
// Verify that the ignored file still exists.
647647
Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(ignoredFilePath));
@@ -723,7 +723,7 @@ public void CheckingOutABranchDoesNotAlterBinaryFiles()
723723
// The blob actually exists in the object database with the correct Sha
724724
Assert.Equal(expectedSha, repo.Lookup<Blob>(expectedSha).Sha);
725725

726-
repo.Checkout("refs/heads/logo", CheckoutOptions.Force, null, null);
726+
repo.Checkout("refs/heads/logo", CheckoutModifiers.Force, null, null);
727727

728728
// The Index has been updated as well with the blob
729729
Assert.Equal(expectedSha, repo.Index["square-logo.png"].Id.Sha);

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public void QueryingTheRemoteForADetachedHeadBranchReturnsNull()
553553
string path = CloneStandardTestRepo();
554554
using (var repo = new Repository(path))
555555
{
556-
repo.Checkout(repo.Head.Tip.Sha, CheckoutOptions.Force, null, null);
556+
repo.Checkout(repo.Head.Tip.Sha, CheckoutModifiers.Force, null, null);
557557
Branch trackLocal = repo.Head;
558558
Assert.Null(trackLocal.Remote);
559559
}

LibGit2Sharp/Branch.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ public virtual void Checkout()
233233
/// </summary>
234234
/// <param name="checkoutOptions">Options controlling checkout behavior.</param>
235235
/// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param>
236-
[Obsolete("This method will be removed in the next release. Please use Checkout(CheckoutOptions, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
236+
[Obsolete("This method will be removed in the next release. Please use Checkout(CheckoutModifiers, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
237237
public virtual void Checkout(CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress)
238238
{
239-
Checkout(checkoutOptions, onCheckoutProgress, null);
239+
Checkout((CheckoutModifiers)checkoutOptions, onCheckoutProgress, null);
240240
}
241241

242242
/// <summary>
@@ -245,12 +245,12 @@ public virtual void Checkout(CheckoutOptions checkoutOptions, CheckoutProgressHa
245245
/// current tip of the branch, will checkout the named branch. Otherwise,
246246
/// will checkout the tip commit as a detached HEAD.
247247
/// </summary>
248-
/// <param name="checkoutOptions">Options controlling checkout behavior.</param>
248+
/// <param name="checkoutModifiers">Options controlling checkout behavior.</param>
249249
/// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param>
250250
/// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param>
251-
public virtual void Checkout(CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions)
251+
public virtual void Checkout(CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions)
252252
{
253-
repo.Checkout(this, checkoutOptions, onCheckoutProgress, checkoutNotificationOptions);
253+
repo.Checkout(this, checkoutModifiers, onCheckoutProgress, checkoutNotificationOptions);
254254
}
255255

256256
private Branch ResolveTrackedBranch()

LibGit2Sharp/CheckoutModifiers.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
3+
namespace LibGit2Sharp
4+
{
5+
/// <summary>
6+
/// Options controlling Checkout behavior.
7+
/// </summary>
8+
[Flags]
9+
public enum CheckoutModifiers
10+
{
11+
/// <summary>
12+
/// No checkout flags - use default behavior.
13+
/// </summary>
14+
None = 0,
15+
16+
/// <summary>
17+
/// Proceed with checkout even if the index or the working tree differs from HEAD.
18+
/// This will throw away local changes.
19+
/// </summary>
20+
Force,
21+
}
22+
}

LibGit2Sharp/CheckoutOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace LibGit2Sharp
66
/// Options controlling Checkout behavior.
77
/// </summary>
88
[Flags]
9+
[Obsolete("This type will be removed in the next release.")]
910
public enum CheckoutOptions
1011
{
1112
/// <summary>

LibGit2Sharp/IRepository.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public interface IRepository : IDisposable
8282
/// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param>
8383
/// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param>
8484
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
85-
[Obsolete("This method will be removed in the next release. Please use Checkout(Branch, CheckoutOptions, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
85+
[Obsolete("This method will be removed in the next release. Please use Checkout(Branch, CheckoutModifiers, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
8686
Branch Checkout(Branch branch, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress);
8787

8888
/// <summary>
@@ -93,11 +93,11 @@ public interface IRepository : IDisposable
9393
/// </para>
9494
/// </summary>
9595
/// <param name="branch">The <see cref = "Branch" /> to check out. </param>
96-
/// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param>
96+
/// <param name="checkoutModifiers"><see cref = "CheckoutModifiers" /> controlling checkout behavior.</param>
9797
/// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param>
9898
/// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param>
9999
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
100-
Branch Checkout(Branch branch, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions);
100+
Branch Checkout(Branch branch, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions);
101101

102102
/// <summary>
103103
/// Checkout the specified branch, reference or SHA.
@@ -110,7 +110,7 @@ public interface IRepository : IDisposable
110110
/// <param name="checkoutOptions">Options controlling checkout behavior.</param>
111111
/// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param>
112112
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
113-
[Obsolete("This method will be removed in the next release. Please use Checkout(string, CheckoutOptions, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
113+
[Obsolete("This method will be removed in the next release. Please use Checkout(string, CheckoutModifiers, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
114114
Branch Checkout(string committishOrBranchSpec, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress);
115115

116116
/// <summary>
@@ -121,11 +121,11 @@ public interface IRepository : IDisposable
121121
/// </para>
122122
/// </summary>
123123
/// <param name = "committishOrBranchSpec">A revparse spec for the commit or branch to checkout.</param>
124-
/// <param name="checkoutOptions">Options controlling checkout behavior.</param>
124+
/// <param name="checkoutModifiers">Options controlling checkout behavior.</param>
125125
/// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param>
126126
/// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param>
127127
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
128-
Branch Checkout(string committishOrBranchSpec, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions);
128+
Branch Checkout(string committishOrBranchSpec, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions);
129129

130130
/// <summary>
131131
/// Checkout the specified <see cref = "LibGit2Sharp.Commit" />.
@@ -137,7 +137,7 @@ public interface IRepository : IDisposable
137137
/// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param>
138138
/// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param>
139139
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
140-
[Obsolete("This method will be removed in the next release. Please use Checkout(Commit, CheckoutOptions, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
140+
[Obsolete("This method will be removed in the next release. Please use Checkout(Commit, CheckoutModifiers, CheckoutProgressHandler, CheckoutNotificationOptions) instead.")]
141141
Branch Checkout(Commit commit, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress);
142142

143143
/// <summary>
@@ -147,11 +147,11 @@ public interface IRepository : IDisposable
147147
/// </para>
148148
/// </summary>
149149
/// <param name="commit">The <see cref = "Commit" /> to check out. </param>
150-
/// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param>
150+
/// <param name="checkoutModifiers"><see cref = "CheckoutModifiers" /> controlling checkout behavior.</param>
151151
/// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param>
152152
/// <param name="checkoutNotificationOptions"><see cref="CheckoutNotificationOptions"/> to manage checkout notifications.</param>
153153
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
154-
Branch Checkout(Commit commit, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions);
154+
Branch Checkout(Commit commit, CheckoutModifiers checkoutModifiers, CheckoutProgressHandler onCheckoutProgress, CheckoutNotificationOptions checkoutNotificationOptions);
155155

156156
/// <summary>
157157
/// Try to lookup an object by its <see cref = "ObjectId" />. If no matching object is found, null will be returned.

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<Compile Include="BranchUpdater.cs" />
6767
<Compile Include="Changes.cs" />
6868
<Compile Include="CheckoutCallbacks.cs" />
69+
<Compile Include="CheckoutModifiers.cs" />
6970
<Compile Include="CheckoutNotificationOptions.cs" />
7071
<Compile Include="CheckoutOptions.cs" />
7172
<Compile Include="CommitFilter.cs" />

0 commit comments

Comments
 (0)
0