forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveSubmodule.cs
More file actions
53 lines (44 loc) · 1.42 KB
/
Copy pathMoveSubmodule.cs
File metadata and controls
53 lines (44 loc) · 1.42 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
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class MoveSubmodule : Popup
{
public Models.Submodule Submodule
{
get;
}
[Required(ErrorMessage = "Path is required!!!")]
public string MoveTo
{
get => _moveTo;
set => SetProperty(ref _moveTo, value, true);
}
public MoveSubmodule(Repository repo, Models.Submodule submodule)
{
_repo = repo;
_moveTo = submodule.Path;
Submodule = submodule;
}
public override async Task<bool> Sure()
{
ProgressDescription = "Moving submodule ...";
var oldPath = Native.OS.GetAbsPath(_repo.FullPath, Submodule.Path);
var newPath = Native.OS.GetAbsPath(_repo.FullPath, _moveTo);
if (oldPath.Equals(newPath, StringComparison.Ordinal))
return true;
var log = _repo.CreateLog("Move Submodule");
_repo.SetWatcherEnabled(false);
Use(log);
var succ = await new Commands.Move(_repo.FullPath, oldPath, newPath, false)
.Use(log)
.ExecAsync();
log.Complete();
_repo.SetWatcherEnabled(true);
return succ;
}
private Repository _repo;
private string _moveTo;
}
}