Skip to content

Studio STUD-6_8_8_3_2: add libgit2 feature info #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading