enhance: do NOT modify repository's local configuration if it is equals to default value

This commit is contained in:
leo 2024-09-13 15:20:52 +08:00
parent 886b242b66
commit cc6e486663
No known key found for this signature in database

View file

@ -138,22 +138,22 @@ namespace SourceGit.ViewModels
public void Save() public void Save()
{ {
SetIfChanged("user.name", UserName); SetIfChanged("user.name", UserName, "");
SetIfChanged("user.email", UserEmail); SetIfChanged("user.email", UserEmail, "");
SetIfChanged("commit.gpgsign", GPGCommitSigningEnabled ? "true" : "false"); SetIfChanged("commit.gpgsign", GPGCommitSigningEnabled ? "true" : "false", "false");
SetIfChanged("tag.gpgsign", GPGTagSigningEnabled ? "true" : "false"); SetIfChanged("tag.gpgsign", GPGTagSigningEnabled ? "true" : "false", "false");
SetIfChanged("user.signingkey", GPGUserSigningKey); SetIfChanged("user.signingkey", GPGUserSigningKey, "");
SetIfChanged("http.proxy", HttpProxy); SetIfChanged("http.proxy", HttpProxy, "");
} }
private void SetIfChanged(string key, string value) private void SetIfChanged(string key, string value, string defValue)
{ {
bool changed = false; bool changed = false;
if (_cached.TryGetValue(key, out var old)) if (_cached.TryGetValue(key, out var old))
{ {
changed = old != value; changed = old != value;
} }
else if (!string.IsNullOrEmpty(value)) else if (!string.IsNullOrEmpty(value) && value != defValue)
{ {
changed = true; changed = true;
} }