mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
fix(dashboard.xaml.cs): 对于 SUBMODULE ,如果发现 HEAD 出于游离状态,这自动切换到找的第一个有效分支
This commit is contained in:
parent
aa017d5f2f
commit
728b4dd879
2 changed files with 11 additions and 2 deletions
|
@ -927,7 +927,7 @@ namespace SourceGit.Git {
|
|||
public void UpdateSubmodule() {
|
||||
isWatcherDisabled = true;
|
||||
|
||||
var errs = RunCommand("submodule update", null);
|
||||
var errs = RunCommand("submodule update --rebase --remote", null);
|
||||
if (errs != null) {
|
||||
App.RaiseError(errs);
|
||||
} else {
|
||||
|
|
|
@ -204,6 +204,8 @@ namespace SourceGit.UI {
|
|||
}
|
||||
|
||||
private void UpdateBranches(bool force = true) {
|
||||
bool IsDetached = false;
|
||||
Git.Branch branch = null;
|
||||
Task.Run(() => {
|
||||
var branches = repo.Branches(force);
|
||||
var remotes = repo.Remotes(true);
|
||||
|
@ -223,6 +225,7 @@ namespace SourceGit.UI {
|
|||
foreach (var b in branches) {
|
||||
if (b.IsLocal) {
|
||||
MakeBranchNode(b, localBranchNodes, folders, states, "locals");
|
||||
branch = b;
|
||||
} else if (!string.IsNullOrEmpty(b.Remote)) {
|
||||
RemoteNode remote = null;
|
||||
|
||||
|
@ -240,6 +243,10 @@ namespace SourceGit.UI {
|
|||
}
|
||||
|
||||
MakeBranchNode(b, remote.Children, folders, states, "remotes");
|
||||
} else {
|
||||
/// 对于 SUBMODULE HEAD 出于游离状态(detached on commit id)
|
||||
/// 此时,分支既不是 本地分支,也不是远程分支
|
||||
IsDetached = b.IsCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,6 +271,8 @@ namespace SourceGit.UI {
|
|||
localBranchTree.ItemsSource = localBranchNodes;
|
||||
remoteBranchTree.ItemsSource = remoteNodes;
|
||||
});
|
||||
|
||||
if (IsDetached && branch != null) repo.Checkout(branch.Name);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue