mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
fix: tag.gpgsign setting not updated
This commit is contained in:
parent
9ae6df4597
commit
86226d5484
3 changed files with 28 additions and 32 deletions
|
@ -14,7 +14,10 @@ namespace SourceGit.Commands
|
|||
|
||||
public Dictionary<string, string> ListAll()
|
||||
{
|
||||
Args = "config -l";
|
||||
if (string.IsNullOrEmpty(WorkingDirectory))
|
||||
Args = "config --global -l";
|
||||
else
|
||||
Args = "config -l";
|
||||
|
||||
var output = ReadToEnd();
|
||||
var rs = new Dictionary<string, string>();
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace SourceGit.ViewModels
|
|||
UserEmail = email;
|
||||
if (_cached.TryGetValue("commit.gpgsign", out var gpgCommitSign))
|
||||
GPGCommitSigningEnabled = gpgCommitSign == "true";
|
||||
if (_cached.TryGetValue("tag.gpgSign", out var gpgTagSign))
|
||||
if (_cached.TryGetValue("tag.gpgsign", out var gpgTagSign))
|
||||
GPGTagSigningEnabled = gpgTagSign == "true";
|
||||
if (_cached.TryGetValue("user.signingkey", out var signingKey))
|
||||
GPGUserSigningKey = signingKey;
|
||||
|
@ -67,7 +67,7 @@ namespace SourceGit.ViewModels
|
|||
SetIfChanged("user.name", UserName);
|
||||
SetIfChanged("user.email", UserEmail);
|
||||
SetIfChanged("commit.gpgsign", GPGCommitSigningEnabled ? "true" : "false");
|
||||
SetIfChanged("tag.gpgSign", GPGTagSigningEnabled ? "true" : "false");
|
||||
SetIfChanged("tag.gpgsign", GPGTagSigningEnabled ? "true" : "false");
|
||||
SetIfChanged("user.signingkey", GPGUserSigningKey);
|
||||
SetIfChanged("http.proxy", HttpProxy);
|
||||
return null;
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace SourceGit.Views
|
|||
CRLFMode = Models.CRLFMode.Supported.Find(x => x.Value == crlf);
|
||||
if (config.TryGetValue("commit.gpgsign", out var gpgCommitSign))
|
||||
EnableGPGCommitSigning = (gpgCommitSign == "true");
|
||||
if (config.TryGetValue("tag.gpgSign", out var gpgTagSign))
|
||||
if (config.TryGetValue("tag.gpgsign", out var gpgTagSign))
|
||||
EnableGPGTagSigning = (gpgTagSign == "true");
|
||||
if (config.TryGetValue("gpg.format", out var gpgFormat))
|
||||
GPGFormat = Models.GPGFormat.Supported.Find(x => x.Value == gpgFormat) ?? Models.GPGFormat.Supported[0];
|
||||
|
@ -181,34 +181,15 @@ namespace SourceGit.Views
|
|||
|
||||
private void CloseWindow(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var cmd = new Commands.Config(null);
|
||||
|
||||
var config = cmd.ListAll();
|
||||
var oldUser = config.TryGetValue("user.name", out var user) ? user : string.Empty;
|
||||
var oldEmail = config.TryGetValue("user.email", out var email) ? email : string.Empty;
|
||||
var oldGPGSignKey = config.TryGetValue("user.signingkey", out var signingKey) ? signingKey : string.Empty;
|
||||
var oldCRLF = config.TryGetValue("core.autocrlf", out var crlf) ? crlf : string.Empty;
|
||||
var oldGPGFormat = config.TryGetValue("gpg.format", out var gpgFormat) ? gpgFormat : "opengpg";
|
||||
var oldGPGCommitSignEnable = config.TryGetValue("commit.gpgsign", out var gpgCommitSign) ? gpgCommitSign : "false";
|
||||
var oldGPGTagSignEnable = config.TryGetValue("tag.gpgSign", out var gpgTagSign) ? gpgTagSign : "false";
|
||||
var oldGPGExec = config.TryGetValue("gpg.program", out var program) ? program : string.Empty;
|
||||
|
||||
if (DefaultUser != oldUser)
|
||||
cmd.Set("user.name", DefaultUser);
|
||||
if (DefaultEmail != oldEmail)
|
||||
cmd.Set("user.email", DefaultEmail);
|
||||
if (GPGUserKey != oldGPGSignKey)
|
||||
cmd.Set("user.signingkey", GPGUserKey);
|
||||
if (CRLFMode != null && CRLFMode.Value != oldCRLF)
|
||||
cmd.Set("core.autocrlf", CRLFMode.Value);
|
||||
if (EnableGPGCommitSigning != (oldGPGCommitSignEnable == "true"))
|
||||
cmd.Set("commit.gpgsign", EnableGPGCommitSigning ? "true" : "false");
|
||||
if (EnableGPGTagSigning != (oldGPGTagSignEnable == "true"))
|
||||
cmd.Set("tag.gpgSign", EnableGPGTagSigning ? "true" : "false");
|
||||
if (GPGFormat.Value != oldGPGFormat)
|
||||
cmd.Set("gpg.format", GPGFormat.Value);
|
||||
if (GPGExecutableFile != oldGPGExec)
|
||||
cmd.Set($"gpg.{GPGFormat.Value}.program", GPGExecutableFile);
|
||||
var config = new Commands.Config(null).ListAll();
|
||||
SetIfChanged(config, "user.name", DefaultUser);
|
||||
SetIfChanged(config, "user.email", DefaultEmail);
|
||||
SetIfChanged(config, "user.signingkey", GPGUserKey);
|
||||
SetIfChanged(config, "core.autocrlf", CRLFMode.Value);
|
||||
SetIfChanged(config, "commit.gpgsign", EnableGPGCommitSigning ? "true" : "false");
|
||||
SetIfChanged(config, "tag.gpgsign", EnableGPGTagSigning ? "true" : "false");
|
||||
SetIfChanged(config, "gpg.format", GPGFormat.Value);
|
||||
SetIfChanged(config, $"gpg.{GPGFormat.Value}.program", GPGFormat.Value != "ssh" ? GPGExecutableFile : null);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -303,5 +284,17 @@ namespace SourceGit.Views
|
|||
ViewModels.Preference.Instance.ExternalMergeToolPath = selected[0].Path.LocalPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetIfChanged(Dictionary<string, string> cached, string key, string value)
|
||||
{
|
||||
bool changed = false;
|
||||
if (cached.TryGetValue(key, out var old))
|
||||
changed = old != value;
|
||||
else if (!string.IsNullOrEmpty(value))
|
||||
changed = true;
|
||||
|
||||
if (changed)
|
||||
new Commands.Config(null).Set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue