optimize<ContextMenu>: auto disable some context menu actions when the branch is at the same point with its upstream

This commit is contained in:
leo 2021-01-15 09:53:58 +08:00
parent 7055ed84b3
commit 5f583e5146
2 changed files with 6 additions and 0 deletions

View file

@ -594,6 +594,7 @@ namespace SourceGit.UI {
var push = new MenuItem(); var push = new MenuItem();
push.Header = App.Format("BranchCM.Push", branch.Name); push.Header = App.Format("BranchCM.Push", branch.Name);
push.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack);
push.Click += (o, e) => { push.Click += (o, e) => {
Push.Show(repo, branch); Push.Show(repo, branch);
e.Handled = true; e.Handled = true;
@ -613,6 +614,7 @@ namespace SourceGit.UI {
var upstream = branch.Upstream.Substring(13); var upstream = branch.Upstream.Substring(13);
var fastForward = new MenuItem(); var fastForward = new MenuItem();
fastForward.Header = App.Format("BranchCM.FastForward", upstream); fastForward.Header = App.Format("BranchCM.FastForward", upstream);
fastForward.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack);
fastForward.Click += (o, e) => { fastForward.Click += (o, e) => {
Merge.StartDirectly(repo, upstream, branch.Name); Merge.StartDirectly(repo, upstream, branch.Name);
e.Handled = true; e.Handled = true;
@ -620,6 +622,7 @@ namespace SourceGit.UI {
var pull = new MenuItem(); var pull = new MenuItem();
pull.Header = App.Format("BranchCM.Pull", upstream); pull.Header = App.Format("BranchCM.Pull", upstream);
pull.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack);
pull.Click += (o, e) => { pull.Click += (o, e) => {
Pull.Show(repo); Pull.Show(repo);
e.Handled = true; e.Handled = true;

View file

@ -227,6 +227,7 @@ namespace SourceGit.UI {
var upstream = branch.Upstream.Substring(13); var upstream = branch.Upstream.Substring(13);
var fastForward = new MenuItem(); var fastForward = new MenuItem();
fastForward.Header = App.Format("BranchCM.FastForward", upstream); fastForward.Header = App.Format("BranchCM.FastForward", upstream);
fastForward.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack);
fastForward.Click += (o, e) => { fastForward.Click += (o, e) => {
Merge.StartDirectly(Repo, upstream, branch.Name); Merge.StartDirectly(Repo, upstream, branch.Name);
e.Handled = true; e.Handled = true;
@ -235,6 +236,7 @@ namespace SourceGit.UI {
var pull = new MenuItem(); var pull = new MenuItem();
pull.Header = App.Format("BranchCM.Pull", upstream); pull.Header = App.Format("BranchCM.Pull", upstream);
pull.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack);
pull.Click += (o, e) => { pull.Click += (o, e) => {
Pull.Show(Repo); Pull.Show(Repo);
e.Handled = true; e.Handled = true;
@ -244,6 +246,7 @@ namespace SourceGit.UI {
var push = new MenuItem(); var push = new MenuItem();
push.Header = App.Format("BranchCM.Push", branch.Name); push.Header = App.Format("BranchCM.Push", branch.Name);
push.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrack);
push.Click += (o, e) => { push.Click += (o, e) => {
Push.Show(Repo, branch); Push.Show(Repo, branch);
e.Handled = true; e.Handled = true;