mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
refactor: use popup to change tracking branch
This commit is contained in:
parent
25a2bf603f
commit
6fe4d8162b
13 changed files with 170 additions and 47 deletions
|
@ -1624,38 +1624,12 @@ namespace SourceGit.ViewModels
|
|||
var tracking = new MenuItem();
|
||||
tracking.Header = App.Text("BranchCM.Tracking");
|
||||
tracking.Icon = App.CreateMenuIcon("Icons.Track");
|
||||
|
||||
foreach (var b in remoteBranches)
|
||||
tracking.Click += (_, e) =>
|
||||
{
|
||||
var upstream = b.FullName.Replace("refs/remotes/", "");
|
||||
var target = new MenuItem();
|
||||
target.Header = upstream;
|
||||
if (branch.Upstream == b.FullName)
|
||||
target.Icon = App.CreateMenuIcon("Icons.Check");
|
||||
|
||||
target.Click += (_, e) =>
|
||||
{
|
||||
if (Commands.Branch.SetUpstream(_fullpath, branch.Name, upstream))
|
||||
Task.Run(RefreshBranches);
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
tracking.Items.Add(target);
|
||||
}
|
||||
|
||||
var unsetUpstream = new MenuItem();
|
||||
unsetUpstream.Header = App.Text("BranchCM.UnsetUpstream");
|
||||
unsetUpstream.Click += (_, e) =>
|
||||
{
|
||||
if (Commands.Branch.SetUpstream(_fullpath, branch.Name, string.Empty))
|
||||
Task.Run(RefreshBranches);
|
||||
|
||||
if (PopupHost.CanCreatePopup())
|
||||
PopupHost.ShowPopup(new SetUpstream(this, branch, remoteBranches));
|
||||
e.Handled = true;
|
||||
};
|
||||
tracking.Items.Add(new MenuItem() { Header = "-" });
|
||||
tracking.Items.Add(unsetUpstream);
|
||||
|
||||
menu.Items.Add(tracking);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue