feature: show commit gpg sign status (#614)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-29 21:03:45 +08:00
parent 5c92fbdb37
commit 279b1819a3
No known key found for this signature in database
7 changed files with 131 additions and 1 deletions

View file

@ -0,0 +1,30 @@
namespace SourceGit.Commands
{
public class QueryCommitSignInfo : Command
{
public QueryCommitSignInfo(string repo, string sha)
{
WorkingDirectory = repo;
Context = repo;
var allowedSignersFile = new Config(repo).Get("gpg.ssh.allowedSignersFile");
if (string.IsNullOrEmpty(allowedSignersFile))
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}";
}
public Models.CommitSignInfo Result()
{
var rs = ReadToEnd();
if (!rs.IsSuccess)
return null;
var raw = rs.StdOut.Trim();
if (raw.Length > 1)
return new Models.CommitSignInfo() { VerifyResult = raw[0], Key = raw.Substring(2) };
return null;
}
}
}