-
Notifications
You must be signed in to change notification settings - Fork 892
/
Copy pathCloneOptions.cs
86 lines (72 loc) · 2.52 KB
/
CloneOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using LibGit2Sharp.Core;
using LibGit2Sharp.Handlers;
namespace LibGit2Sharp
{
/// <summary>
/// Options to define clone behavior
/// </summary>
public sealed class CloneOptions : IConvertableToGitCheckoutOpts
{
/// <summary>
/// Creates <see cref="CloneOptions"/> with specified <see cref="FetchOptions"/> for a non-bare clone.
/// </summary>
/// <param name="fetchOptions">The fetch options to use.</param>
public CloneOptions(FetchOptions fetchOptions) : this()
{
Ensure.ArgumentNotNull(fetchOptions, "fetchOptions");
FetchOptions = fetchOptions;
}
/// <summary>
/// Creates default <see cref="CloneOptions"/> for a non-bare clone.
/// </summary>
public CloneOptions()
{
Checkout = true;
}
/// <summary>
/// True will result in a bare clone, false a full clone.
/// </summary>
public bool IsBare { get; set; }
/// <summary>
/// If true, the origin's HEAD will be checked out. This only applies
/// to non-bare repositories.
/// </summary>
public bool Checkout { get; set; }
/// <summary>
/// The name of the branch to checkout. When unspecified the
/// remote's default branch will be used instead.
/// </summary>
public string BranchName { get; set; }
/// <summary>
/// Recursively clone submodules.
/// </summary>
public bool RecurseSubmodules { get; set; }
/// <summary>
/// Handler for checkout progress information.
/// </summary>
public CheckoutProgressHandler OnCheckoutProgress { get; set; }
/// <summary>
/// Gets or sets the fetch options.
/// </summary>
public FetchOptions FetchOptions { get; } = new();
#region IConvertableToGitCheckoutOpts
CheckoutCallbacks IConvertableToGitCheckoutOpts.GenerateCallbacks()
{
return CheckoutCallbacks.From(OnCheckoutProgress, null);
}
CheckoutStrategy IConvertableToGitCheckoutOpts.CheckoutStrategy
{
get
{
return this.Checkout
? CheckoutStrategy.GIT_CHECKOUT_SAFE
: CheckoutStrategy.GIT_CHECKOUT_NONE;
}
}
CheckoutNotifyFlags IConvertableToGitCheckoutOpts.CheckoutNotifyFlags
{
get { return CheckoutNotifyFlags.None; }
}
#endregion
}
}