mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00

* refactor: Update submodules individually to avoid failures (#925) - Remove `--recurse-submodules` flag from the clone command to simplify the cloning process. - Refactor submodule update logic to handle updating all submodules in a loop and improve progress description handling. * fix: Parse submodule list even if submodule status fails (#935)
86 lines
2.1 KiB
C#
86 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.ViewModels
|
|
{
|
|
public class UpdateSubmodules : Popup
|
|
{
|
|
public List<string> Submodules
|
|
{
|
|
get;
|
|
private set;
|
|
} = new List<string>();
|
|
|
|
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;
|
|
|
|
foreach (var submodule in _repo.Submodules)
|
|
Submodules.Add(submodule.Path);
|
|
|
|
SelectedSubmodule = Submodules.Count > 0 ? Submodules[0] : string.Empty;
|
|
View = new Views.UpdateSubmodules() { DataContext = this };
|
|
}
|
|
|
|
public override Task<bool> Sure()
|
|
{
|
|
_repo.SetWatcherEnabled(false);
|
|
|
|
List<string> targets;
|
|
if (_updateAll)
|
|
targets = Submodules;
|
|
else
|
|
targets = [SelectedSubmodule];
|
|
|
|
return Task.Run(() =>
|
|
{
|
|
foreach (var submodule in targets)
|
|
{
|
|
ProgressDescription = $"Updating submodule {submodule} ...";
|
|
new Commands.Submodule(_repo.FullPath).Update(
|
|
submodule,
|
|
EnableInit,
|
|
EnableRecursive,
|
|
EnableRemote,
|
|
SetProgressDescription);
|
|
}
|
|
|
|
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
|
return true;
|
|
});
|
|
}
|
|
|
|
private readonly Repository _repo = null;
|
|
private bool _updateAll = true;
|
|
}
|
|
}
|