diff --git a/src/Commands/QueryCommitSignInfo.cs b/src/Commands/QueryCommitSignInfo.cs index 95f6d4d6..18517d8d 100644 --- a/src/Commands/QueryCommitSignInfo.cs +++ b/src/Commands/QueryCommitSignInfo.cs @@ -7,10 +7,9 @@ WorkingDirectory = repo; Context = repo; - if (useFakeSignersFile) - Args = $"-c gpg.ssh.allowedSignersFile=/dev/null show --no-show-signature --pretty=format:\"%G? %GK\" -s {sha}"; - else - Args = $"show --no-show-signature --pretty=format:\"%G? %GK\" -s {sha}"; + const string baseArgs = "show --no-show-signature --pretty=format:\"%G?%n%GS%n%GK\" -s"; + const string fakeSignersFileArg = "-c gpg.ssh.allowedSignersFile=/dev/null"; + Args = $"{(useFakeSignersFile ? fakeSignersFileArg : string.Empty)} {baseArgs} {sha}"; } public Models.CommitSignInfo Result() @@ -20,10 +19,17 @@ return null; var raw = rs.StdOut.Trim(); - if (raw.Length > 1) - return new Models.CommitSignInfo() { VerifyResult = raw[0], Key = raw.Substring(2) }; + if (raw.Length <= 1) + return null; + + var lines = raw.Split('\n'); + return new Models.CommitSignInfo() + { + VerifyResult = lines[0][0], + Signer = string.IsNullOrEmpty(lines[1]) ? "" : lines[1], + Key = lines[2] + }; - return null; } } } diff --git a/src/Models/CommitSignInfo.cs b/src/Models/CommitSignInfo.cs index 2428b2af..ab2bfbf4 100644 --- a/src/Models/CommitSignInfo.cs +++ b/src/Models/CommitSignInfo.cs @@ -4,8 +4,9 @@ namespace SourceGit.Models { public class CommitSignInfo { - public string Key { get; set; } = string.Empty; - public char VerifyResult { get; set; } = 'N'; + public char VerifyResult { get; init; } = 'N'; + public string Signer { get; init; } = string.Empty; + public string Key { get; init; } = string.Empty; public IBrush Brush { @@ -36,19 +37,19 @@ namespace SourceGit.Models switch (VerifyResult) { case 'G': - return $"Good signature.\n\nKey: {Key}"; + return $"Good signature.\n\nSigner: {Signer}\n\nKey: {Key}"; case 'B': - return $"Bad signature.\n\nKey: {Key}"; + return $"Bad signature.\n\nSigner: {Signer}\n\nKey: {Key}"; case 'U': - return $"Good signature with unknown validity.\n\nKey: {Key}"; + return $"Good signature with unknown validity.\n\nSigner: {Signer}\n\nKey: {Key}"; case 'X': - return $"Good signature but has expired.\n\nKey: {Key}"; + return $"Good signature but has expired.\n\nSigner: {Signer}\n\nKey: {Key}"; case 'Y': - return $"Good signature made by expired key.\n\nKey: {Key}"; + return $"Good signature made by expired key.\n\nSigner: {Signer}\n\nKey: {Key}"; case 'R': - return $"Good signature made by a revoked key.\n\nKey: {Key}"; + return $"Good signature made by a revoked key.\n\nSigner: {Signer}\n\nKey: {Key}"; case 'E': - return $"Signature cannot be checked.\n\nKey: {Key}"; + return $"Signature cannot be checked.\n\nSigner: {Signer}\n\nKey: {Key}"; default: return "No signature."; }