Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LibGit2Sharp.Tests/GlobalSettingsFixture.cs19
-rw-r--r--LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj3
-rw-r--r--LibGit2Sharp/BuiltInFeatures.cs33
-rw-r--r--LibGit2Sharp/Core/GitBuiltInFeatures.cs18
-rw-r--r--LibGit2Sharp/Core/Proxy.cs10
-rw-r--r--LibGit2Sharp/GlobalSettings.cs20
-rw-r--r--LibGit2Sharp/LibGit2Sharp.csproj3
-rw-r--r--LibGit2Sharp/Repository.cs4
8 files changed, 80 insertions, 30 deletions
diff --git a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs
new file mode 100644
index 00000000..29935903
--- /dev/null
+++ b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs
@@ -0,0 +1,19 @@
+using System;
+using LibGit2Sharp;
+using LibGit2Sharp.Tests.TestHelpers;
+using Xunit;
+
+namespace LibGit2Sharp.Tests
+{
+ public class GlobalSettingsFixture : BaseFixture
+ {
+ [Fact]
+ public void CanGetMinimumCompiledInFeatures()
+ {
+ BuiltInFeatures features = GlobalSettings.Features();
+
+ Assert.True(features.HasFlag(BuiltInFeatures.Threads));
+ Assert.True(features.HasFlag(BuiltInFeatures.Https));
+ }
+ }
+}
diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
index 9c0809b2..b07fcec4 100644
--- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
+++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -62,6 +62,7 @@
<Compile Include="BlameFixture.cs" />
<Compile Include="ArchiveTarFixture.cs" />
<Compile Include="CheckoutFixture.cs" />
+ <Compile Include="GlobalSettingsFixture.cs" />
<Compile Include="PatchStatsFixture.cs" />
<Compile Include="RefSpecFixture.cs" />
<Compile Include="EqualityFixture.cs" />
@@ -147,4 +148,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project> \ No newline at end of file
+</Project>
diff --git a/LibGit2Sharp/BuiltInFeatures.cs b/LibGit2Sharp/BuiltInFeatures.cs
new file mode 100644
index 00000000..db6a1a0e
--- /dev/null
+++ b/LibGit2Sharp/BuiltInFeatures.cs
@@ -0,0 +1,33 @@
+using System;
+
+namespace LibGit2Sharp
+{
+ /// <summary>
+ /// Flags to identify libgit2 compiled features.
+ /// </summary>
+ [Flags]
+ public enum BuiltInFeatures
+ {
+ /// <summary>
+ /// No optional features are compiled into libgit2.
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// Threading support is compiled into libgit2.
+ /// </summary>
+ Threads = (1 << 0),
+
+ /// <summary>
+ /// Support for remotes over the HTTPS protocol is compiled into
+ /// libgit2.
+ /// </summary>
+ Https = (1 << 1),
+
+ /// <summary>
+ /// Support for remotes over the SSH protocol is compiled into
+ /// libgit2.
+ /// </summary>
+ Ssh = (1 << 2),
+ }
+}
diff --git a/LibGit2Sharp/Core/GitBuiltInFeatures.cs b/LibGit2Sharp/Core/GitBuiltInFeatures.cs
deleted file mode 100644
index 4163b318..00000000
--- a/LibGit2Sharp/Core/GitBuiltInFeatures.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace LibGit2Sharp.Core
-{
- /// <summary>
- /// Flags to indentify libgit compiled features.
- /// </summary>
- [Flags]
- internal enum GitBuiltInFeatures
- {
- Threads = (1 << 0),
- Https = (1 << 1),
- Ssh = (1 << 2),
- }
-}
diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs
index 2da9a5dc..f3fc97dd 100644
--- a/LibGit2Sharp/Core/Proxy.cs
+++ b/LibGit2Sharp/Core/Proxy.cs
@@ -2754,15 +2754,9 @@ namespace LibGit2Sharp.Core
/// <summary>
/// Returns the features with which libgit2 was compiled.
/// </summary>
- public static string git_libgit2_features()
+ public static BuiltInFeatures git_libgit2_features()
{
- GitBuiltInFeatures features;
-
- int flags = NativeMethods.git_libgit2_features();
-
- features = (GitBuiltInFeatures)Enum.ToObject(typeof(GitBuiltInFeatures), flags);
-
- return features.ToString();
+ return (BuiltInFeatures)NativeMethods.git_libgit2_features();
}
#endregion
diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs
new file mode 100644
index 00000000..0e01ef57
--- /dev/null
+++ b/LibGit2Sharp/GlobalSettings.cs
@@ -0,0 +1,20 @@
+using LibGit2Sharp.Core;
+
+namespace LibGit2Sharp
+{
+ /// <summary>
+ /// Global settings for libgit2 and LibGit2Sharp.
+ /// </summary>
+ public static class GlobalSettings
+ {
+ /// <summary>
+ /// Returns all the optional features that were compiled into
+ /// libgit2.
+ /// </summary>
+ /// <returns>A <see cref="BuiltInFeatures"/> enumeration.</returns>
+ public static BuiltInFeatures Features()
+ {
+ return Proxy.git_libgit2_features();
+ }
+ }
+}
diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj
index a2d083ca..7e476d93 100644
--- a/LibGit2Sharp/LibGit2Sharp.csproj
+++ b/LibGit2Sharp/LibGit2Sharp.csproj
@@ -79,7 +79,7 @@
<Compile Include="CommitSortStrategies.cs" />
<Compile Include="CompareOptions.cs" />
<Compile Include="ContentChangeStats.cs" />
- <Compile Include="Core\GitBuiltInFeatures.cs" />
+ <Compile Include="BuiltInFeatures.cs" />
<Compile Include="Core\GitCheckoutOptsWrapper.cs" />
<Compile Include="Core\GitCredentialType.cs" />
<Compile Include="Core\GitRevertOpts.cs" />
@@ -88,6 +88,7 @@
<Compile Include="DefaultCredentials.cs" />
<Compile Include="EmptyCommitException.cs" />
<Compile Include="FetchOptions.cs" />
+ <Compile Include="GlobalSettings.cs" />
<Compile Include="MergeOptions.cs" />
<Compile Include="MergeResult.cs" />
<Compile Include="PatchStats.cs" />
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 91231a76..b80f47fc 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -1067,6 +1067,7 @@ namespace LibGit2Sharp
string libgit2Hash = ReadContentFromResource(assembly, "libgit2_hash.txt");
string libgit2sharpHash = ReadContentFromResource(assembly, "libgit2sharp_hash.txt");
+ string features = GlobalSettings.Features().ToString();
return string.Format(
CultureInfo.InvariantCulture,
@@ -1075,8 +1076,7 @@ namespace LibGit2Sharp
libgit2sharpHash.Substring(0, 7),
libgit2Hash.Substring(0, 7),
NativeMethods.ProcessorArchitecture,
- Proxy.git_libgit2_features()
- );
+ features);
}
private static string ReadContentFromResource(Assembly assembly, string partialResourceName)