mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 20:54:59 +00:00
feature: show commit gpg sign status (#614)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
5c92fbdb37
commit
279b1819a3
7 changed files with 131 additions and 1 deletions
30
src/Commands/QueryCommitSignInfo.cs
Normal file
30
src/Commands/QueryCommitSignInfo.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue