mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-02 01:34:58 +00:00
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:
parent
054bbf7e0c
commit
df29edd8f0
10 changed files with 80 additions and 11 deletions
|
@ -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}");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue