diff --git a/CustomDictionary.xml b/CustomDictionary.xml
index 0f5443f0dd..5bb0276c70 100644
--- a/CustomDictionary.xml
+++ b/CustomDictionary.xml
@@ -25,6 +25,7 @@
Tarball
Unsuspend
Zipball
+ Gpg
diff --git a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs
index aa46429f66..6ccf365a2a 100644
--- a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs
@@ -43,4 +43,21 @@ public async Task CanCreateAndRetrieveCommit()
Assert.NotNull(retrieved);
}
}
+
+ [IntegrationTest]
+ public async Task CanDeserializeVerificationObjectInResponse()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ var commit = await github.Git.Commit.Get("noonari", "Signature-Verification", "1965d149ce1151cf411300d15f8d890d9259bd21");
+
+ Assert.False(commit.Verification.Verified);
+ Assert.Equal(commit.Verification.Signature,
+ "-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQEcBAABAgAGBQJXYT2BAAoJEJyZ1vxIV0+N9ZwIAKlf3dk9n1q1mD5AT3Ahtj9o\nF4H25zsHynJk2lnH4YxVvDBEc/uMCXzX6orihZiSdA5UXE7tPyEEZddQdp8pxulX\ncIsFKcrfQqHJnTbT90z5PhAk94lyN9fFngzPW1tgZZVjp2YiiqgXduBWWm6EREOh\nS1Iu9wBqScQomhTXoksmNZyGTZ0LviSi0pkqRY64pQhKnpLlu1OFXaeDvhYocB+E\nY5URZsXodvIkBuzCkWCu8ra4eaXIIARkas4+jIvn0FIx9CzEVz0Zau/5Fk+BR+Te\n7a3/7JH7yuObPB0hqPSuFYyxtvPfxtayvhkGD3YkQqDAkWCpISGyVFzxrrC7z0Y=\n=kbih\n-----END PGP SIGNATURE-----");
+
+ Assert.Equal(commit.Verification.Payload,
+ "tree c91c844f37974093a3f0a864755441b577e7663a\nparent 6eb645f6badd46de65700b4d7b6fcdb97684ce5a\nauthor noonari 1465990529 +0500\ncommitter noonari 1465990529 +0500\n\ngpg stuff\n");
+
+ Assert.Equal(commit.Verification.Reason, VerificationReason.UnknownKey);
+ }
}
\ No newline at end of file
diff --git a/Octokit.Tests/Clients/CommitsClientTests.cs b/Octokit.Tests/Clients/CommitsClientTests.cs
index 6c1c420168..72d3dafff6 100644
--- a/Octokit.Tests/Clients/CommitsClientTests.cs
+++ b/Octokit.Tests/Clients/CommitsClientTests.cs
@@ -31,7 +31,7 @@ public void RequestsCorrectUrl()
client.Get("owner", "repo", "reference");
- connection.Received().Get(Arg.Is(u => u.ToString() == "repos/owner/repo/git/commits/reference"));
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repos/owner/repo/git/commits/reference"), Arg.Any>(), "application/vnd.github.cryptographer-preview+sha");
}
}
diff --git a/Octokit/Clients/CommitsClient.cs b/Octokit/Clients/CommitsClient.cs
index ea5588ea09..555b661736 100644
--- a/Octokit/Clients/CommitsClient.cs
+++ b/Octokit/Clients/CommitsClient.cs
@@ -35,7 +35,7 @@ public Task Get(string owner, string name, string reference)
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
- return ApiConnection.Get(ApiUrls.Commit(owner, name, reference));
+ return ApiConnection.Get(ApiUrls.Commit(owner, name, reference), null, AcceptHeaders.SignatureVerificationPreview);
}
///
diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs
index 0002896ac7..b9c762772b 100644
--- a/Octokit/Helpers/AcceptHeaders.cs
+++ b/Octokit/Helpers/AcceptHeaders.cs
@@ -27,7 +27,9 @@ public static class AcceptHeaders
public const string MigrationsApiPreview = "application/vnd.github.wyandotte-preview+json";
public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview";
-
+
+ public const string SignatureVerificationPreview = "application/vnd.github.cryptographer-preview+sha";
+
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
public const string GpgKeysPreview = "application/vnd.github.cryptographer-preview";
}
diff --git a/Octokit/Models/Response/Commit.cs b/Octokit/Models/Response/Commit.cs
index 374398c0bb..7023193790 100644
--- a/Octokit/Models/Response/Commit.cs
+++ b/Octokit/Models/Response/Commit.cs
@@ -34,5 +34,7 @@ public Commit(string url, string label, string @ref, string sha, User user, Repo
public IReadOnlyList Parents { get; protected set; }
public int CommentCount { get; protected set; }
+
+ public Verification Verification { get; protected set; }
}
}
diff --git a/Octokit/Models/Response/Verification.cs b/Octokit/Models/Response/Verification.cs
new file mode 100644
index 0000000000..fdc703bf3f
--- /dev/null
+++ b/Octokit/Models/Response/Verification.cs
@@ -0,0 +1,90 @@
+using System.Diagnostics;
+using System.Globalization;
+using Octokit.Internal;
+
+namespace Octokit
+{
+ ///
+ /// Represents a Signature Verification Object in Git Data Commit Payload.
+ ///
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ public class Verification
+ {
+ ///
+ /// Does GitHub consider the signature in this commit to be verified?
+ ///
+ public bool Verified { get; protected set; }
+
+ ///
+ /// The reason for verified value.
+ ///
+ [Parameter(Key = "reason")]
+ public VerificationReason Reason { get; protected set; }
+
+ ///
+ /// The signature that was extracted from the commit.
+ ///
+ public string Signature { get; protected set; }
+
+ ///
+ /// The value that was signed.
+ ///
+ public string Payload { get; protected set; }
+
+ internal string DebuggerDisplay
+ {
+ get
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "Verification: {0} Verified: {1} Reason: {2} Signature: {3} Payload",
+ Verified,
+ Reason.ToString(),
+ Signature,
+ Payload);
+ }
+ }
+ }
+
+ public enum VerificationReason
+ {
+ [Parameter(Value = "expired_key")]
+ ExpiredKey,
+
+ [Parameter(Value = "not_signing_key")]
+ NotSigningKey,
+
+ [Parameter(Value = "gpgverify_error")]
+ GpgVerifyError,
+
+ [Parameter(Value = "gpgverify_unavailable")]
+ GpgVerifyUnavailable,
+
+ [Parameter(Value = "unsigned")]
+ Unsigned,
+
+ [Parameter(Value = "unknown_signature_type")]
+ UnknownSignatureType,
+
+ [Parameter(Value = "no_user")]
+ NoUser,
+
+ [Parameter(Value = "unverified_email")]
+ UnverifiedEmail,
+
+ [Parameter(Value = "bad_email")]
+ BadEmail,
+
+ [Parameter(Value = "unknown_key")]
+ UnknownKey,
+
+ [Parameter(Value = "malformed_signature")]
+ MalformedSignature,
+
+ [Parameter(Value = "inavlid")]
+ Invalid,
+
+ [Parameter(Value = "valid")]
+ Valid
+ }
+}
diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj
index 6a0db8dd3c..7c6a3564f6 100644
--- a/Octokit/Octokit-Mono.csproj
+++ b/Octokit/Octokit-Mono.csproj
@@ -484,6 +484,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 928b8440ba..8b66b03d30 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -495,6 +495,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index b0d416fe45..68b0e6ff83 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -491,6 +491,7 @@
+
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index ee2e5bc965..c7a7f4fa47 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -481,6 +481,7 @@
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index 7ac0288d97..3d7d9a74d8 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -488,6 +488,7 @@
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index 6c21d844fa..29da34ce5c 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -394,6 +394,7 @@
+