feature: make --recurse-submdoules an option while trying to checkout branch with submodules (#1272)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-06 11:12:57 +08:00
parent 054bbf7e0c
commit df29edd8f0
No known key found for this signature in database
10 changed files with 80 additions and 11 deletions

View file

@ -15,11 +15,24 @@ namespace SourceGit.ViewModels
set;
}
public bool IsRecurseSubmoduleVisible
{
get;
private set;
}
public bool RecurseSubmodules
{
get => _repo.Settings.UpdateSubmodulesOnCheckoutBranch;
set => _repo.Settings.UpdateSubmodulesOnCheckoutBranch = value;
}
public Checkout(Repository repo, string branch)
{
_repo = repo;
Branch = branch;
DiscardLocalChanges = false;
IsRecurseSubmoduleVisible = repo.Submodules.Count > 0;
}
public override Task<bool> Sure()
@ -30,6 +43,7 @@ namespace SourceGit.ViewModels
var log = _repo.CreateLog($"Checkout '{Branch}'");
Use(log);
var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules;
return Task.Run(() =>
{
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
@ -54,7 +68,7 @@ namespace SourceGit.ViewModels
}
}
var rs = new Commands.Checkout(_repo.FullPath).Use(log).Branch(Branch);
var rs = new Commands.Checkout(_repo.FullPath).Use(log).Branch(Branch, updateSubmodules);
if (needPopStash)
rs = new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}");