mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor: update submodule (#287)
This commit is contained in:
parent
58c685627f
commit
7bfb684bde
7 changed files with 127 additions and 17 deletions
|
@ -1,28 +1,82 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class UpdateSubmodules : Popup
|
||||
{
|
||||
public List<string> Submodules
|
||||
{
|
||||
get => _repo.Submodules;
|
||||
}
|
||||
|
||||
public string SelectedSubmodule
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool UpdateAll
|
||||
{
|
||||
get => _updateAll;
|
||||
set => SetProperty(ref _updateAll, value);
|
||||
}
|
||||
|
||||
public bool EnableInit
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = true;
|
||||
|
||||
public bool EnableRecursive
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = true;
|
||||
|
||||
public bool EnableRemote
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public UpdateSubmodules(Repository repo)
|
||||
{
|
||||
_repo = repo;
|
||||
SelectedSubmodule = repo.Submodules.Count > 0 ? repo.Submodules[0] : string.Empty;
|
||||
View = new Views.UpdateSubmodules() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "Updating submodules ...";
|
||||
|
||||
string target = string.Empty;
|
||||
if (_updateAll)
|
||||
{
|
||||
ProgressDescription = "Updating submodules ...";
|
||||
}
|
||||
else
|
||||
{
|
||||
target = SelectedSubmodule;
|
||||
ProgressDescription = $"Updating submodule {target} ...";
|
||||
}
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
new Commands.Submodule(_repo.FullPath).Update(SetProgressDescription);
|
||||
new Commands.Submodule(_repo.FullPath).Update(
|
||||
target,
|
||||
EnableInit,
|
||||
EnableRecursive,
|
||||
EnableRemote,
|
||||
SetProgressDescription);
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private bool _updateAll = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue