style: add .editorconfig for code formatting. see issu #25

This commit is contained in:
leo 2024-03-18 09:37:06 +08:00
parent a8eeea4f78
commit 18aaa0a143
225 changed files with 7781 additions and 3911 deletions

View file

@ -1,34 +1,42 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels {
public class RepositoryConfigure : Popup {
public string UserName {
namespace SourceGit.ViewModels
{
public class RepositoryConfigure : Popup
{
public string UserName
{
get;
set;
}
public string UserEmail {
public string UserEmail
{
get;
set;
}
public bool GPGSigningEnabled {
public bool GPGSigningEnabled
{
get;
set;
}
public string GPGUserSigningKey {
public string GPGUserSigningKey
{
get;
set;
}
public string HttpProxy {
public string HttpProxy
{
get;
set;
}
public RepositoryConfigure(Repository repo) {
public RepositoryConfigure(Repository repo)
{
_repo = repo;
_cached = new Commands.Config(repo.FullPath).ListAll();
@ -41,7 +49,8 @@ namespace SourceGit.ViewModels {
View = new Views.RepositoryConfigure() { DataContext = this };
}
public override Task<bool> Sure() {
public override Task<bool> Sure()
{
SetIfChanged("user.name", UserName);
SetIfChanged("user.email", UserEmail);
SetIfChanged("commit.gpgsign", GPGSigningEnabled ? "true" : "false");
@ -50,20 +59,25 @@ namespace SourceGit.ViewModels {
return null;
}
private void SetIfChanged(string key, string value) {
private void SetIfChanged(string key, string value)
{
bool changed = false;
if (_cached.ContainsKey(key)) {
if (_cached.ContainsKey(key))
{
changed = value != _cached[key];
} else if (!string.IsNullOrEmpty(value)) {
}
else if (!string.IsNullOrEmpty(value))
{
changed = true;
}
if (changed) {
if (changed)
{
new Commands.Config(_repo.FullPath).Set(key, value);
}
}
private Repository _repo = null;
private Dictionary<string, string> _cached = null;
private readonly Repository _repo = null;
private readonly Dictionary<string, string> _cached = null;
}
}
}