mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24: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
|
@ -3,92 +3,114 @@ using System.ComponentModel.DataAnnotations;
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels {
|
||||
public class Clone : Popup {
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class Clone : Popup
|
||||
{
|
||||
[Required(ErrorMessage = "Remote URL is required")]
|
||||
[CustomValidation(typeof(Clone), nameof(ValidateRemote))]
|
||||
public string Remote {
|
||||
public string Remote
|
||||
{
|
||||
get => _remote;
|
||||
set {
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _remote, value, true)) UseSSH = Models.Remote.IsSSH(value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseSSH {
|
||||
public bool UseSSH
|
||||
{
|
||||
get => _useSSH;
|
||||
set => SetProperty(ref _useSSH, value);
|
||||
}
|
||||
|
||||
public string SSHKey {
|
||||
public string SSHKey
|
||||
{
|
||||
get => _sshKey;
|
||||
set => SetProperty(ref _sshKey, value);
|
||||
}
|
||||
|
||||
[Required(ErrorMessage = "Parent folder is required")]
|
||||
[CustomValidation(typeof(Clone), nameof(ValidateParentFolder))]
|
||||
public string ParentFolder {
|
||||
public string ParentFolder
|
||||
{
|
||||
get => _parentFolder;
|
||||
set => SetProperty(ref _parentFolder, value, true);
|
||||
}
|
||||
|
||||
public string Local {
|
||||
public string Local
|
||||
{
|
||||
get => _local;
|
||||
set => SetProperty(ref _local, value);
|
||||
}
|
||||
|
||||
public string ExtraArgs {
|
||||
public string ExtraArgs
|
||||
{
|
||||
get => _extraArgs;
|
||||
set => SetProperty(ref _extraArgs, value);
|
||||
}
|
||||
|
||||
public Clone(Launcher launcher, LauncherPage page) {
|
||||
public Clone(Launcher launcher, LauncherPage page)
|
||||
{
|
||||
_launcher = launcher;
|
||||
_page = page;
|
||||
|
||||
View = new Views.Clone() { DataContext = this };
|
||||
}
|
||||
|
||||
public static ValidationResult ValidateRemote(string remote, ValidationContext _) {
|
||||
public static ValidationResult ValidateRemote(string remote, ValidationContext _)
|
||||
{
|
||||
if (!Models.Remote.IsValidURL(remote)) return new ValidationResult("Invalid remote repository URL format");
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
public static ValidationResult ValidateParentFolder(string folder, ValidationContext _) {
|
||||
public static ValidationResult ValidateParentFolder(string folder, ValidationContext _)
|
||||
{
|
||||
if (!Directory.Exists(folder)) return new ValidationResult("Given path can NOT be found");
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
public override Task<bool> Sure() {
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
ProgressDescription = "Clone ...";
|
||||
|
||||
return Task.Run(() => {
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var cmd = new Commands.Clone(HostPageId, _parentFolder, _remote, _local, _useSSH ? _sshKey : "", _extraArgs, SetProgressDescription);
|
||||
if (!cmd.Exec()) return false;
|
||||
|
||||
var path = _parentFolder;
|
||||
if (!string.IsNullOrEmpty(_local)) {
|
||||
if (!string.IsNullOrEmpty(_local))
|
||||
{
|
||||
path = Path.GetFullPath(Path.Combine(path, _local));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = Path.GetFileName(_remote);
|
||||
if (name.EndsWith(".git")) name = name.Substring(0, name.Length - 4);
|
||||
path = Path.GetFullPath(Path.Combine(path, name));
|
||||
}
|
||||
|
||||
if (!Directory.Exists(path)) {
|
||||
CallUIThread(() => {
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
CallUIThread(() =>
|
||||
{
|
||||
App.RaiseException(HostPageId, $"Folder '{path}' can NOT be found");
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_useSSH && !string.IsNullOrEmpty(_sshKey)) {
|
||||
if (_useSSH && !string.IsNullOrEmpty(_sshKey))
|
||||
{
|
||||
var config = new Commands.Config(path);
|
||||
config.Set("remote.origin.sshkey", _sshKey);
|
||||
}
|
||||
|
||||
CallUIThread(() => {
|
||||
CallUIThread(() =>
|
||||
{
|
||||
var repo = Preference.AddRepository(path, Path.Combine(path, ".git"));
|
||||
var node = new RepositoryNode() {
|
||||
var node = new RepositoryNode()
|
||||
{
|
||||
Id = repo.FullPath,
|
||||
Name = Path.GetFileName(repo.FullPath),
|
||||
Bookmark = 0,
|
||||
|
@ -103,8 +125,8 @@ namespace SourceGit.ViewModels {
|
|||
});
|
||||
}
|
||||
|
||||
private Launcher _launcher = null;
|
||||
private LauncherPage _page = null;
|
||||
private readonly Launcher _launcher = null;
|
||||
private readonly LauncherPage _page = null;
|
||||
private string _remote = string.Empty;
|
||||
private bool _useSSH = false;
|
||||
private string _sshKey = string.Empty;
|
||||
|
@ -112,4 +134,4 @@ namespace SourceGit.ViewModels {
|
|||
private string _local = string.Empty;
|
||||
private string _extraArgs = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue