Skip to content

Commit 4162bcd

Browse files
Merge pull request #26 from UiPath/feautre/libgit_feature_query
Studio STUD-6_8_8_3_2: add libgit2 feature info
2 parents 457d706 + 85d41fe commit 4162bcd

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
9696
{
9797
Trace.TraceInformation("Using git with schannel");
9898
libraryName = libraryName + "_schannel";
99+
GlobalSettings.SetHttpBackend(HttpsBackend.Schannel);
99100
}
100101

101102
// Use GlobalSettings.NativeLibraryPath when set.

LibGit2Sharp/GlobalSettings.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static class GlobalSettings
2121
private static string nativeLibraryPath;
2222
private static bool nativeLibraryPathLocked;
2323
private static readonly string nativeLibraryDefaultPath = null;
24+
private static HttpsBackend httpsBackend = HttpsBackend.WinHttp;
2425

2526
static GlobalSettings()
2627
{
@@ -420,5 +421,43 @@ public static string GetUserAgent()
420421
{
421422
return Proxy.git_libgit2_opts_get_user_agent();
422423
}
424+
425+
/// <summary>
426+
/// Check libgit supported features
427+
/// </summary>
428+
public static bool HasFeature(LibGitFeature feature)
429+
{
430+
return feature switch
431+
{
432+
LibGitFeature.DefaultCredentials => httpsBackend == HttpsBackend.WinHttp,
433+
_ => false
434+
};
435+
}
436+
437+
internal static void SetHttpBackend(HttpsBackend backend)
438+
{
439+
httpsBackend = backend;
440+
}
441+
}
442+
443+
/// <summary>
444+
/// List of supported libgit features
445+
/// </summary>
446+
public enum LibGitFeature
447+
{
448+
/// <summary>
449+
/// Not used
450+
/// </summary>
451+
None,
452+
/// <summary>
453+
/// When supported, returning 'null' from the credentials manager acts as fallback attempt like using Windows authentication for WinHttp transport
454+
/// </summary>
455+
DefaultCredentials
456+
}
457+
458+
internal enum HttpsBackend
459+
{
460+
WinHttp,
461+
Schannel
423462
}
424463
}

0 commit comments

Comments
 (0)