mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-22 02:45:00 +00:00
34 lines
1 KiB
C#
34 lines
1 KiB
C#
namespace SourceGit.Commands
|
|
{
|
|
public class QueryCommitSignInfo : Command
|
|
{
|
|
public QueryCommitSignInfo(string repo, string sha, bool useFakeSignersFile)
|
|
{
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
|
|
const string baseArgs = "show --no-show-signature --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()
|
|
{
|
|
var rs = ReadToEnd();
|
|
if (!rs.IsSuccess)
|
|
return null;
|
|
|
|
var raw = rs.StdOut.Trim().ReplaceLineEndings("\n");
|
|
if (raw.Length <= 1)
|
|
return null;
|
|
|
|
var lines = raw.Split('\n');
|
|
return new Models.CommitSignInfo()
|
|
{
|
|
VerifyResult = lines[0][0],
|
|
Signer = lines[1],
|
|
Key = lines[2]
|
|
};
|
|
}
|
|
}
|
|
}
|