mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-07 11:54:59 +00:00
feature: supports --recurse-submodules
on pull (#1342)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
d73ae83b01
commit
936160ea5c
9 changed files with 46 additions and 14 deletions
|
@ -17,8 +17,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public bool IsRecurseSubmoduleVisible
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
get => _repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public bool RecurseSubmodules
|
||||
|
@ -32,7 +31,6 @@ namespace SourceGit.ViewModels
|
|||
_repo = repo;
|
||||
Branch = branch;
|
||||
DiscardLocalChanges = false;
|
||||
IsRecurseSubmoduleVisible = repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public bool IsRecurseSubmoduleVisible
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
get => _repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public bool RecurseSubmodules
|
||||
|
@ -32,7 +31,6 @@ namespace SourceGit.ViewModels
|
|||
_repo = repo;
|
||||
Commit = commit;
|
||||
DiscardLocalChanges = false;
|
||||
IsRecurseSubmoduleVisible = repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
|
|
|
@ -45,8 +45,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public bool IsRecurseSubmoduleVisible
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
get => _repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public bool RecurseSubmodules
|
||||
|
@ -67,7 +66,6 @@ namespace SourceGit.ViewModels
|
|||
|
||||
BasedOn = branch;
|
||||
DiscardLocalChanges = false;
|
||||
IsRecurseSubmoduleVisible = repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public CreateBranch(Repository repo, Models.Commit commit)
|
||||
|
@ -77,7 +75,6 @@ namespace SourceGit.ViewModels
|
|||
|
||||
BasedOn = commit;
|
||||
DiscardLocalChanges = false;
|
||||
IsRecurseSubmoduleVisible = repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public CreateBranch(Repository repo, Models.Tag tag)
|
||||
|
@ -87,7 +84,6 @@ namespace SourceGit.ViewModels
|
|||
|
||||
BasedOn = tag;
|
||||
DiscardLocalChanges = false;
|
||||
IsRecurseSubmoduleVisible = repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public static ValidationResult ValidateBranchName(string name, ValidationContext ctx)
|
||||
|
|
|
@ -48,7 +48,14 @@ namespace SourceGit.ViewModels
|
|||
|
||||
protected void Use(CommandLog log)
|
||||
{
|
||||
log.Register(newline => ProgressDescription = newline.Trim());
|
||||
log.Register(SetDescription);
|
||||
}
|
||||
|
||||
private void SetDescription(string data)
|
||||
{
|
||||
var desc = data.Trim();
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
ProgressDescription = desc;
|
||||
}
|
||||
|
||||
private bool _inProgress = false;
|
||||
|
|
|
@ -62,6 +62,17 @@ namespace SourceGit.ViewModels
|
|||
set => _repo.Settings.FetchWithoutTagsOnPull = value;
|
||||
}
|
||||
|
||||
public bool IsRecurseSubmoduleVisible
|
||||
{
|
||||
get => _repo.Submodules.Count > 0;
|
||||
}
|
||||
|
||||
public bool RecurseSubmodules
|
||||
{
|
||||
get => _repo.Settings.UpdateSubmodulesOnCheckoutBranch;
|
||||
set => _repo.Settings.UpdateSubmodulesOnCheckoutBranch = value;
|
||||
}
|
||||
|
||||
public Pull(Repository repo, Models.Branch specifiedRemoteBranch)
|
||||
{
|
||||
_repo = repo;
|
||||
|
@ -119,6 +130,7 @@ namespace SourceGit.ViewModels
|
|||
var log = _repo.CreateLog("Pull");
|
||||
Use(log);
|
||||
|
||||
var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules;
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result();
|
||||
|
@ -176,8 +188,18 @@ namespace SourceGit.ViewModels
|
|||
NoTags).Use(log).Exec();
|
||||
}
|
||||
|
||||
if (rs && needPopStash)
|
||||
rs = new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}");
|
||||
if (rs)
|
||||
{
|
||||
if (updateSubmodules)
|
||||
{
|
||||
var submodules = new Commands.QuerySubmodules(_repo.FullPath).Result();
|
||||
if (submodules.Count > 0)
|
||||
new Commands.Submodule(_repo.FullPath).Use(log).Update(submodules, true, true, false);
|
||||
}
|
||||
|
||||
if (needPopStash)
|
||||
new Commands.Stash(_repo.FullPath).Use(log).Pop("stash@{0}");
|
||||
}
|
||||
|
||||
log.Complete();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue