Skip to content
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
20 changes: 13 additions & 7 deletions src/Commands/QueryCommitSignInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ public QueryCommitSignInfo(string repo, string sha, bool useFakeSignersFile)
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()
Expand All @@ -20,10 +19,17 @@ public Models.CommitSignInfo Result()
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]) ? "<UnKnown>" : lines[1],
Key = lines[2]
};

return null;
}
}
}
19 changes: 10 additions & 9 deletions src/Models/CommitSignInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -36,19 +37,19 @@ public string ToolTip
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.";
}
Expand Down