8000 Convert repo.Checkout() overloads into extensions methods · ben/libgit2sharp@2734620 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2734620

Browse files
committed
Convert repo.Checkout() overloads into extensions methods
1 parent 2559030 commit 2734620

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

LibGit2Sharp/Branch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public virtual Remote Remote
193193
/// </summary>
194194
public virtual void Checkout()
195195
{
196-
repo.CheckoutInternal(CanonicalName, CheckoutOptions.None, null);
196+
repo.Checkout(this);
197197
}
198198

199199
/// <summary>
@@ -203,7 +203,7 @@ public virtual void Checkout()
203203
/// <param name="onCheckoutProgress">Callback method to report checkout progress updates through.</param>
204204
public virtual void Checkout(CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress)
205205
{
206-
repo.CheckoutInternal(CanonicalName, checkoutOptions, onCheckoutProgress);
206+
repo.Checkout(this, checkoutOptions, onCheckoutProgress);
207207
}
208208

209209
private Branch ResolveTrackedBranch()

LibGit2Sharp/Repository.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -440,16 +440,6 @@ public static Repository Clone(string sourceUrl, string workdirPath,
440440
return new Repository(workdirPath);
441441
}
442442

443-
/// <summary>
444-
/// Checkout the specified <see cref = "Branch" />, reference or SHA.
445-
/// </summary>
446-
/// <param name = "commitOrBranchSpec">A revparse spec for the commit or branch to checkout.</param>
447-
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
448-
public Branch Checkout(string commitOrBranchSpec)
449-
{
450-
return Checkout(commitOrBranchSpec, CheckoutOptions.None, null);
451-
}
452-
453443
/// <summary>
454444
/// Checkout the specified <see cref = "Branch" />, reference or SHA.
455445
/// </summary>
@@ -470,16 +460,6 @@ public Branch Checkout(string commitishOrBranchSpec, CheckoutOptions checkoutOpt
470460
return CheckoutInternal(commitId.Sha, checkoutOptions, onCheckoutProgress);
471461
}
472462

473-
/// <summary>
474-
/// Checkout the specified <see cref = "Branch" />.
475-
/// </summary>
476-
/// <param name="branch">The <see cref = "Branch" /> to check out.</param>
477-
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
478-
public Branch Checkout(Branch branch)
479-
{
480-
return Checkout(branch, CheckoutOptions.None, null);
481-
}
482-
483463
/// <summary>
484464
/// Checkout the specified <see cref = "Branch" />.
485465
/// </summary>
@@ -502,7 +482,7 @@ public Branch Checkout(Branch branch, CheckoutOptions checkoutOptions, CheckoutP
502482
/// <param name="checkoutOptions"><see cref = "CheckoutOptions" /> controlling checkout behavior.</param>
503483
/// <param name="onCheckoutProgress"><see cref = "CheckoutProgressHandler" /> that checkout progress is reported through.</param>
504484
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
505-
internal Branch CheckoutInternal(string commitIdOrCanonicalBranchName, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress)
485+
private Branch CheckoutInternal(string commitIdOrCanonicalBranchName, CheckoutOptions checkoutOptions, CheckoutProgressHandler onCheckoutProgress)
506486
{
507487
if (Info.IsBare)
508488
{

LibGit2Sharp/RepositoryExtensions.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,28 @@ private static Signature BuildSignatureFromGlobalConfiguration(IRepository repos
183183

184184
return new Signature(name.Value, email.Value, now);
185185
}
186+
187+
/// <summary>
188+
/// Checkout the specified <see cref = "Branch" />, reference or SHA.
189+
/// </summary>
190+
/// <param name="repository">The <see cref = "Repository" /> being worked with.</param>
191+
/// <param name = "commitOrBranchSpec">A revparse spec for the commit or branch to checkout.</param>
192+
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
193+
public static Branch Checkout(this IRepository repository, string commitOrBranchSpec)
194+
{
195+
return repository.Checkout(commitOrBranchSpec, CheckoutOptions.None, null);
196+
}
197+
198+
199+
/// <summary>
200+
/// Checkout the specified <see cref = "Branch" />.
201+
/// </summary>
202+
/// <param name="repository">The <see cref = "Repository" /> being worked with.</param>
203+
/// <param name="branch">The <see cref = "Branch" /> to check out.</param>
204+
/// <returns>The <see cref = "Branch" /> that was checked out.</returns>
205+
public static Branch Checkout(this IRepository repository, Branch branch)
206+
{
207+
return repository.Checkout(branch, CheckoutOptions.None, null);
208+
}
186209
}
187210
}

0 commit comments

Comments
 (0)
0