forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeSubmoduleUrl.cs
More file actions
59 lines (48 loc) · 1.61 KB
/
ChangeSubmoduleUrl.cs
File metadata and controls
59 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class ChangeSubmoduleUrl : Popup
{
public Models.Submodule Submodule
{
get;
}
[Required(ErrorMessage = "Url is required!!!")]
[CustomValidation(typeof(ChangeSubmoduleUrl), nameof(ValidateUrl))]
public string Url
{
get => _url;
set => SetProperty(ref _url, value, true);
}
public ChangeSubmoduleUrl(Repository repo, Models.Submodule submodule)
{
_repo = repo;
_url = submodule.URL;
Submodule = submodule;
}
public static ValidationResult ValidateUrl(string url, ValidationContext ctx)
{
if (!Models.Remote.IsValidURL(url))
return new ValidationResult("Invalid repository URL format");
return ValidationResult.Success;
}
public override async Task<bool> Sure()
{
if (_url.Equals(Submodule.URL, StringComparison.Ordinal))
return true;
using var lockWatcher = _repo.LockWatcher();
ProgressDescription = "Change submodule's url...";
var log = _repo.CreateLog("Change Submodule's URL");
Use(log);
var succ = await new Commands.Submodule(_repo.FullPath)
.Use(log)
.SetURLAsync(Submodule.Path, _url);
log.Complete();
return succ;
}
private readonly Repository _repo;
private string _url;
}
}