mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +00:00
enhance: update submodules individually (#1272)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
6cf1b20ea6
commit
3e530de9cc
4 changed files with 24 additions and 14 deletions
|
@ -11,17 +11,15 @@ namespace SourceGit.Commands
|
|||
Context = repo;
|
||||
}
|
||||
|
||||
public bool Branch(string branch, bool recurseSubmodules)
|
||||
public bool Branch(string branch)
|
||||
{
|
||||
var options = recurseSubmodules ? "--recurse-submodules" : string.Empty;
|
||||
Args = $"checkout {options} --progress {branch}";
|
||||
Args = $"checkout --force --progress {branch}";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public bool Branch(string branch, string basedOn, bool recurseSubmodules)
|
||||
public bool Branch(string branch, string basedOn)
|
||||
{
|
||||
var options = recurseSubmodules ? "--recurse-submodules" : string.Empty;
|
||||
Args = $"checkout {options} --progress -b {branch} {basedOn}";
|
||||
Args = $"checkout --force --progress -b {branch} {basedOn}";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,15 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
var rs = new Commands.Checkout(_repo.FullPath).Use(log).Branch(Branch, updateSubmodules);
|
||||
if (needPopStash)
|
||||
var rs = new Commands.Checkout(_repo.FullPath).Use(log).Branch(Branch);
|
||||
if (rs && updateSubmodules)
|
||||
{
|
||||
var submodules = new Commands.QuerySubmodules(_repo.FullPath).Result();
|
||||
foreach (var submodule in submodules)
|
||||
new Commands.Submodule(_repo.FullPath).Use(log).Update(submodule.Path, true, true, false);
|
||||
}
|
||||
|
||||
if (rs && needPopStash)
|
||||
rs = new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}");
|
||||
|
||||
log.Complete();
|
||||
|
|
|
@ -101,7 +101,6 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
ProgressDescription = "Clone ...";
|
||||
|
||||
// Create a temp log.
|
||||
var log = new CommandLog("Clone");
|
||||
Use(log);
|
||||
|
||||
|
@ -139,11 +138,10 @@ namespace SourceGit.ViewModels
|
|||
config.Set("remote.origin.sshkey", _sshKey);
|
||||
}
|
||||
|
||||
// individually update submodule (if any)
|
||||
if (InitAndUpdateSubmodules)
|
||||
{
|
||||
var submoduleList = new Commands.QuerySubmodules(path).Result();
|
||||
foreach (var submodule in submoduleList)
|
||||
var submodules = new Commands.QuerySubmodules(path).Result();
|
||||
foreach (var submodule in submodules)
|
||||
new Commands.Submodule(path).Use(log).Update(submodule.Path, true, true, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,8 +142,15 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(fixedName, _baseOnRevision, updateSubmodules);
|
||||
if (needPopStash)
|
||||
succ = new Commands.Checkout(_repo.FullPath).Use(log).Branch(fixedName, _baseOnRevision);
|
||||
if (succ && updateSubmodules)
|
||||
{
|
||||
var submodules = new Commands.QuerySubmodules(_repo.FullPath).Result();
|
||||
foreach (var submodule in submodules)
|
||||
new Commands.Submodule(_repo.FullPath).Use(log).Update(submodule.Path, true, true, false);
|
||||
}
|
||||
|
||||
if (succ && needPopStash)
|
||||
new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}");
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue