feature<Dashboard>: add context menu "Tracking" to change upstream of selected local branch

This commit is contained in:
leo 2020-11-04 11:54:09 +08:00
parent 5e6ef8abcb
commit 19bccbecf6
4 changed files with 66 additions and 6 deletions

View file

@ -153,6 +153,19 @@ namespace SourceGit.Git {
if (errs != null) App.RaiseError(errs);
}
/// <summary>
/// Change upstream
/// </summary>
/// <param name="repo"></param>
/// <param name="upstream"></param>
public void SetUpstream(Repository repo, string upstream) {
var errs = repo.RunCommand($"branch {Name} -u {upstream}", null);
if (errs != null) App.RaiseError(errs);
repo.Branches(true);
repo.OnBranchChanged?.Invoke();
}
/// <summary>
/// Delete branch.
/// </summary>

View file

@ -835,6 +835,18 @@ namespace SourceGit.Git {
return cachedBranches;
}
/// <summary>
/// Get all remote branches
/// </summary>
/// <returns>All remote branches</returns>
public List<Branch> RemoteBranches() {
var ret = new List<Branch>();
foreach (var b in cachedBranches) {
if (!b.IsLocal) ret.Add(b);
}
return ret;
}
/// <summary>
/// Get current branch
/// </summary>