Skip to content

Commit

Permalink
Merge pull request #26 from UiPath/feautre/libgit_feature_query
Browse files Browse the repository at this point in the history
Studio STUD-6_8_8_3_2: add libgit2 feature info
  • Loading branch information
andrei-balint authored Apr 10, 2024
2 parents 457d706 + 85d41fe commit 4162bcd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
{
Trace.TraceInformation("Using git with schannel");
libraryName = libraryName + "_schannel";
GlobalSettings.SetHttpBackend(HttpsBackend.Schannel);
}

// Use GlobalSettings.NativeLibraryPath when set.
Expand Down
39 changes: 39 additions & 0 deletions LibGit2Sharp/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static class GlobalSettings
private static string nativeLibraryPath;
private static bool nativeLibraryPathLocked;
private static readonly string nativeLibraryDefaultPath = null;
private static HttpsBackend httpsBackend = HttpsBackend.WinHttp;

static GlobalSettings()
{
Expand Down Expand Up @@ -420,5 +421,43 @@ public static string GetUserAgent()
{
return Proxy.git_libgit2_opts_get_user_agent();
}

/// <summary>
/// Check libgit supported features
/// </summary>
public static bool HasFeature(LibGitFeature feature)
{
return feature switch
{
LibGitFeature.DefaultCredentials => httpsBackend == HttpsBackend.WinHttp,
_ => false
};
}

internal static void SetHttpBackend(HttpsBackend backend)
{
httpsBackend = backend;
}
}

/// <summary>
/// List of supported libgit features
/// </summary>
public enum LibGitFeature
{
/// <summary>
/// Not used
/// </summary>
None,
/// <summary>
/// When supported, returning 'null' from the credentials manager acts as fallback attempt like using Windows authentication for WinHttp transport
/// </summary>
DefaultCredentials
}

internal enum HttpsBackend
{
WinHttp,
Schannel
}
}

0 comments on commit 4162bcd

Please sign in to comment.