Fetch only added remote; Show remote has no branches

This commit is contained in:
leo 2020-07-09 09:35:49 +08:00
parent 9691fd33a8
commit dbd7a13705
2 changed files with 1093 additions and 1081 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace SourceGit.Git { namespace SourceGit.Git {
@ -57,7 +57,7 @@ namespace SourceGit.Git {
if (errs != null) { if (errs != null) {
App.RaiseError(errs); App.RaiseError(errs);
} else { } else {
repo.Fetch(null, true, null); repo.Fetch(new Remote() { Name = name }, true, null);
} }
} }

View file

@ -197,6 +197,7 @@ namespace SourceGit.UI {
private void UpdateBranches(bool force = true) { private void UpdateBranches(bool force = true) {
Task.Run(() => { Task.Run(() => {
var branches = repo.Branches(force); var branches = repo.Branches(force);
var remotes = repo.Remotes(true);
var localBranchNodes = new List<BranchNode>(); var localBranchNodes = new List<BranchNode>();
var remoteNodes = new List<RemoteNode>(); var remoteNodes = new List<RemoteNode>();
var remoteMap = new Dictionary<string, RemoteNode>(); var remoteMap = new Dictionary<string, RemoteNode>();
@ -233,6 +234,17 @@ namespace SourceGit.UI {
} }
} }
foreach (var r in remotes) {
if (!remoteMap.ContainsKey(r.Name)) {
var remote = new RemoteNode() {
Name = r.Name,
IsExpanded = false,
Children = new List<BranchNode>(),
};
remoteNodes.Add(remote);
}
}
SortBranchNodes(localBranchNodes); SortBranchNodes(localBranchNodes);
foreach (var r in remoteNodes) SortBranchNodes(r.Children); foreach (var r in remoteNodes) SortBranchNodes(r.Children);