mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
enhance: show commit signer (#626)
Signed-off-by: Gadfly <gadfly@gadfly.vip>
This commit is contained in:
parent
e680f8477e
commit
4e87b25765
2 changed files with 23 additions and 16 deletions
|
@ -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]) ? "<UnKnown>" : lines[1],
|
||||
Key = lines[2]
|
||||
};
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue