mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
style: add .editorconfig for code formatting. see issu #25
This commit is contained in:
parent
a8eeea4f78
commit
18aaa0a143
225 changed files with 7781 additions and 3911 deletions
|
@ -1,48 +1,59 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
public partial class Preference : Window {
|
||||
public string DefaultUser {
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class Preference : Window
|
||||
{
|
||||
public string DefaultUser
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string DefaultEmail {
|
||||
public string DefaultEmail
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Models.CRLFMode CRLFMode {
|
||||
public Models.CRLFMode CRLFMode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool EnableGPGSigning {
|
||||
public bool EnableGPGSigning
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string GPGExecutableFile {
|
||||
public string GPGExecutableFile
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string GPGUserKey {
|
||||
public string GPGUserKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Preference() {
|
||||
public Preference()
|
||||
{
|
||||
var pref = ViewModels.Preference.Instance;
|
||||
DataContext = pref;
|
||||
|
||||
var ver = string.Empty;
|
||||
if (pref.IsGitConfigured) {
|
||||
if (pref.IsGitConfigured)
|
||||
{
|
||||
var config = new Commands.Config(null).ListAll();
|
||||
|
||||
if (config.ContainsKey("user.name")) DefaultUser = config["user.name"];
|
||||
|
@ -59,11 +70,13 @@ namespace SourceGit.Views {
|
|||
txtVersion.Text = ver;
|
||||
}
|
||||
|
||||
private void BeginMoveWindow(object sender, PointerPressedEventArgs e) {
|
||||
private void BeginMoveWindow(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
|
||||
private void CloseWindow(object sender, RoutedEventArgs e) {
|
||||
private void CloseWindow(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var cmd = new Commands.Config(null);
|
||||
|
||||
var config = cmd.ListAll();
|
||||
|
@ -78,21 +91,24 @@ namespace SourceGit.Views {
|
|||
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 (EnableGPGSigning != (oldGPGSignEnable == "true")) cmd.Set("commit.gpgsign", EnableGPGSigning ? "true" : "false");
|
||||
if (EnableGPGSigning != (oldGPGSignEnable == "true")) cmd.Set("commit.gpgsign", EnableGPGSigning ? "true" : "false");
|
||||
if (GPGExecutableFile != oldGPGExec) cmd.Set("gpg.program", GPGExecutableFile);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private async void SelectGitExecutable(object sender, RoutedEventArgs e) {
|
||||
private async void SelectGitExecutable(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var pattern = OperatingSystem.IsWindows() ? "git.exe" : "git";
|
||||
var options = new FilePickerOpenOptions() {
|
||||
FileTypeFilter = [new FilePickerFileType("Git Executable") { Patterns = [ pattern ] }],
|
||||
var options = new FilePickerOpenOptions()
|
||||
{
|
||||
FileTypeFilter = [new FilePickerFileType("Git Executable") { Patterns = [pattern] }],
|
||||
AllowMultiple = false,
|
||||
};
|
||||
|
||||
var selected = await StorageProvider.OpenFilePickerAsync(options);
|
||||
if (selected.Count == 1) {
|
||||
if (selected.Count == 1)
|
||||
{
|
||||
ViewModels.Preference.Instance.GitInstallPath = selected[0].Path.LocalPath;
|
||||
txtVersion.Text = new Commands.Version().Query();
|
||||
}
|
||||
|
@ -100,45 +116,54 @@ namespace SourceGit.Views {
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void SelectDefaultCloneDir(object sender, RoutedEventArgs e) {
|
||||
private async void SelectDefaultCloneDir(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var options = new FolderPickerOpenOptions() { AllowMultiple = false };
|
||||
var selected = await StorageProvider.OpenFolderPickerAsync(options);
|
||||
if (selected.Count == 1) {
|
||||
if (selected.Count == 1)
|
||||
{
|
||||
ViewModels.Preference.Instance.GitDefaultCloneDir = selected[0].Path.LocalPath;
|
||||
}
|
||||
}
|
||||
|
||||
private async void SelectGPGExecutable(object sender, RoutedEventArgs e) {
|
||||
private async void SelectGPGExecutable(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var pattern = OperatingSystem.IsWindows() ? "gpg.exe" : "gpg";
|
||||
var options = new FilePickerOpenOptions() {
|
||||
FileTypeFilter = [new FilePickerFileType("GPG Executable") { Patterns = [ pattern ] }],
|
||||
var options = new FilePickerOpenOptions()
|
||||
{
|
||||
FileTypeFilter = [new FilePickerFileType("GPG Executable") { Patterns = [pattern] }],
|
||||
AllowMultiple = false,
|
||||
};
|
||||
|
||||
var selected = await StorageProvider.OpenFilePickerAsync(options);
|
||||
if (selected.Count == 1) {
|
||||
if (selected.Count == 1)
|
||||
{
|
||||
GPGExecutableFile = selected[0].Path.LocalPath;
|
||||
}
|
||||
}
|
||||
|
||||
private async void SelectExternalMergeTool(object sender, RoutedEventArgs e) {
|
||||
private async void SelectExternalMergeTool(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var type = ViewModels.Preference.Instance.ExternalMergeToolType;
|
||||
if (type < 0 || type >= Models.ExternalMergeTools.Supported.Count) {
|
||||
if (type < 0 || type >= Models.ExternalMergeTools.Supported.Count)
|
||||
{
|
||||
ViewModels.Preference.Instance.ExternalMergeToolType = 0;
|
||||
type = 0;
|
||||
}
|
||||
|
||||
var tool = Models.ExternalMergeTools.Supported[type];
|
||||
var pattern = Path.GetFileName(tool.Exec);
|
||||
var options = new FilePickerOpenOptions() {
|
||||
var options = new FilePickerOpenOptions()
|
||||
{
|
||||
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = [pattern] }],
|
||||
AllowMultiple = false,
|
||||
};
|
||||
|
||||
var selected = await StorageProvider.OpenFilePickerAsync(options);
|
||||
if (selected.Count == 1) {
|
||||
if (selected.Count == 1)
|
||||
{
|
||||
ViewModels.Preference.Instance.ExternalMergeToolPath = selected[0].Path.LocalPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue