Skip to content

Commit 1adcf4d

Browse files
committed
enhance: do NOT query gpg.ssh.allowedSignersFile every time while getting commit's signing status
Signed-off-by: leo <[email protected]>
1 parent c2e8377 commit 1adcf4d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Commands/QueryCommitSignInfo.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
{
33
public class QueryCommitSignInfo : Command
44
{
5-
public QueryCommitSignInfo(string repo, string sha)
5+
public QueryCommitSignInfo(string repo, string sha, bool useFakeSignersFile)
66
{
77
WorkingDirectory = repo;
88
Context = repo;
99

10-
var allowedSignersFile = new Config(repo).Get("gpg.ssh.allowedSignersFile");
11-
if (string.IsNullOrEmpty(allowedSignersFile))
10+
if (useFakeSignersFile)
1211
Args = $"-c gpg.ssh.allowedSignersFile=/dev/null show --no-show-signature --pretty=format:\"%G? %GK\" -s {sha}";
1312
else
1413
Args = $"show --no-show-signature --pretty=format:\"%G? %GK\" -s {sha}";

src/ViewModels/CommitDetail.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ private void Refresh()
498498

499499
Task.Run(() =>
500500
{
501-
var signInfo = new Commands.QueryCommitSignInfo(_repo.FullPath, _commit.SHA).Result();
501+
var signInfo = new Commands.QueryCommitSignInfo(_repo.FullPath, _commit.SHA, !_repo.HasAllowedSignersFile).Result();
502502
Dispatcher.UIThread.Invoke(() => SignInfo = signInfo);
503503
});
504504

src/ViewModels/Repository.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public Models.RepositorySettings Settings
4545
get => _settings;
4646
}
4747

48+
public bool HasAllowedSignersFile
49+
{
50+
get => _hasAllowedSignersFile;
51+
}
52+
4853
public int SelectedViewIndex
4954
{
5055
get => _selectedViewIndex;
@@ -444,6 +449,12 @@ public void Close()
444449

445450
public void RefreshAll()
446451
{
452+
Task.Run(() =>
453+
{
454+
var allowedSignersFile = new Commands.Config(_fullpath).Get("gpg.ssh.allowedSignersFile");
455+
_hasAllowedSignersFile = !string.IsNullOrEmpty(allowedSignersFile);
456+
});
457+
447458
Task.Run(() =>
448459
{
449460
RefreshBranches();
@@ -2135,6 +2146,7 @@ private void AutoFetchImpl(object sender)
21352146
private string _fullpath = string.Empty;
21362147
private string _gitDir = string.Empty;
21372148
private Models.RepositorySettings _settings = null;
2149+
private bool _hasAllowedSignersFile = false;
21382150

21392151
private Models.Watcher _watcher = null;
21402152
private Histories _histories = null;

0 commit comments

Comments
 (0)