mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-23 01:36:57 -08:00
enhance: disable unused context menus for bare
repository (#899)
This commit is contained in:
parent
a9327274c6
commit
766b60d05e
4 changed files with 397 additions and 362 deletions
|
@ -420,34 +420,37 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(patch);
|
||||
menu.Items.Add(new MenuItem { Header = "-" });
|
||||
|
||||
var resetToThisRevision = new MenuItem();
|
||||
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
|
||||
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
||||
resetToThisRevision.Click += (_, ev) =>
|
||||
if (!_repo.IsBare)
|
||||
{
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.Path, $"{_commit.SHA}");
|
||||
ev.Handled = true;
|
||||
};
|
||||
var resetToThisRevision = new MenuItem();
|
||||
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
|
||||
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
||||
resetToThisRevision.Click += (_, ev) =>
|
||||
{
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.Path, $"{_commit.SHA}");
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var resetToFirstParent = new MenuItem();
|
||||
resetToFirstParent.Header = App.Text("ChangeCM.CheckoutFirstParentRevision");
|
||||
resetToFirstParent.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
||||
resetToFirstParent.IsEnabled = _commit.Parents.Count > 0;
|
||||
resetToFirstParent.Click += (_, ev) =>
|
||||
{
|
||||
if (change.Index == Models.ChangeState.Renamed)
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.OriginalPath, $"{_commit.SHA}~1");
|
||||
var resetToFirstParent = new MenuItem();
|
||||
resetToFirstParent.Header = App.Text("ChangeCM.CheckoutFirstParentRevision");
|
||||
resetToFirstParent.Icon = App.CreateMenuIcon("Icons.File.Checkout");
|
||||
resetToFirstParent.IsEnabled = _commit.Parents.Count > 0;
|
||||
resetToFirstParent.Click += (_, ev) =>
|
||||
{
|
||||
if (change.Index == Models.ChangeState.Renamed)
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.OriginalPath, $"{_commit.SHA}~1");
|
||||
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.Path, $"{_commit.SHA}~1");
|
||||
ev.Handled = true;
|
||||
};
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(change.Path, $"{_commit.SHA}~1");
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(resetToThisRevision);
|
||||
menu.Items.Add(resetToFirstParent);
|
||||
menu.Items.Add(new MenuItem { Header = "-" });
|
||||
menu.Items.Add(resetToThisRevision);
|
||||
menu.Items.Add(resetToFirstParent);
|
||||
menu.Items.Add(new MenuItem { Header = "-" });
|
||||
|
||||
if (File.Exists(Path.Combine(fullPath)))
|
||||
TryToAddContextMenuItemsForGitLFS(menu, change.Path);
|
||||
if (File.Exists(Path.Combine(fullPath)))
|
||||
TryToAddContextMenuItemsForGitLFS(menu, change.Path);
|
||||
}
|
||||
|
||||
var copyPath = new MenuItem();
|
||||
copyPath.Header = App.Text("CopyPath");
|
||||
|
|
|
@ -253,36 +253,39 @@ namespace SourceGit.ViewModels
|
|||
|
||||
var multipleMenu = new ContextMenu();
|
||||
|
||||
if (canCherryPick)
|
||||
if (!_repo.IsBare)
|
||||
{
|
||||
var cherryPickMultiple = new MenuItem();
|
||||
cherryPickMultiple.Header = App.Text("CommitCM.CherryPickMultiple");
|
||||
cherryPickMultiple.Icon = App.CreateMenuIcon("Icons.CherryPick");
|
||||
cherryPickMultiple.Click += (_, e) =>
|
||||
if (canCherryPick)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new CherryPick(_repo, selected));
|
||||
e.Handled = true;
|
||||
};
|
||||
multipleMenu.Items.Add(cherryPickMultiple);
|
||||
}
|
||||
var cherryPickMultiple = new MenuItem();
|
||||
cherryPickMultiple.Header = App.Text("CommitCM.CherryPickMultiple");
|
||||
cherryPickMultiple.Icon = App.CreateMenuIcon("Icons.CherryPick");
|
||||
cherryPickMultiple.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new CherryPick(_repo, selected));
|
||||
e.Handled = true;
|
||||
};
|
||||
multipleMenu.Items.Add(cherryPickMultiple);
|
||||
}
|
||||
|
||||
if (canMerge)
|
||||
{
|
||||
var mergeMultiple = new MenuItem();
|
||||
mergeMultiple.Header = App.Text("CommitCM.MergeMultiple");
|
||||
mergeMultiple.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
mergeMultiple.Click += (_, e) =>
|
||||
if (canMerge)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new MergeMultiple(_repo, selected));
|
||||
e.Handled = true;
|
||||
};
|
||||
multipleMenu.Items.Add(mergeMultiple);
|
||||
}
|
||||
var mergeMultiple = new MenuItem();
|
||||
mergeMultiple.Header = App.Text("CommitCM.MergeMultiple");
|
||||
mergeMultiple.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
mergeMultiple.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new MergeMultiple(_repo, selected));
|
||||
e.Handled = true;
|
||||
};
|
||||
multipleMenu.Items.Add(mergeMultiple);
|
||||
}
|
||||
|
||||
if (canCherryPick || canMerge)
|
||||
multipleMenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
if (canCherryPick || canMerge)
|
||||
multipleMenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
var saveToPatchMultiple = new MenuItem();
|
||||
saveToPatchMultiple.Icon = App.CreateMenuIcon("Icons.Diff");
|
||||
|
@ -394,25 +397,48 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
if (current.Head != commit.SHA)
|
||||
if (!_repo.IsBare)
|
||||
{
|
||||
var reset = new MenuItem();
|
||||
reset.Header = new Views.NameHighlightedTextBlock("CommitCM.Reset", current.Name);
|
||||
reset.Icon = App.CreateMenuIcon("Icons.Reset");
|
||||
reset.Click += (_, e) =>
|
||||
if (current.Head != commit.SHA)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Reset(_repo, current, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(reset);
|
||||
var reset = new MenuItem();
|
||||
reset.Header = new Views.NameHighlightedTextBlock("CommitCM.Reset", current.Name);
|
||||
reset.Icon = App.CreateMenuIcon("Icons.Reset");
|
||||
reset.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Reset(_repo, current, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(reset);
|
||||
|
||||
if (commit.IsMerged)
|
||||
if (commit.IsMerged)
|
||||
{
|
||||
var squash = new MenuItem();
|
||||
squash.Header = App.Text("CommitCM.SquashCommitsSinceThis");
|
||||
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
|
||||
squash.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Squash(_repo, commit, commit.SHA));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(squash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var squash = new MenuItem();
|
||||
squash.Header = App.Text("CommitCM.SquashCommitsSinceThis");
|
||||
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
|
||||
squash.Click += (_, e) =>
|
||||
var reword = new MenuItem();
|
||||
reword.Header = App.Text("CommitCM.Reword");
|
||||
reword.Icon = App.CreateMenuIcon("Icons.Edit");
|
||||
reword.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
|
@ -421,169 +447,149 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Squash(_repo, commit, commit.SHA));
|
||||
_repo.ShowPopup(new Reword(_repo, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(reword);
|
||||
|
||||
var squash = new MenuItem();
|
||||
squash.Header = App.Text("CommitCM.Squash");
|
||||
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
|
||||
squash.IsEnabled = commit.Parents.Count == 1;
|
||||
squash.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (commit.Parents.Count == 1)
|
||||
{
|
||||
var parent = _commits.Find(x => x.SHA == commit.Parents[0]);
|
||||
if (parent != null && _repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Squash(_repo, parent, commit.SHA));
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(squash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var reword = new MenuItem();
|
||||
reword.Header = App.Text("CommitCM.Reword");
|
||||
reword.Icon = App.CreateMenuIcon("Icons.Edit");
|
||||
reword.Click += (_, e) =>
|
||||
|
||||
if (!commit.IsMerged)
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Reword(_repo, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(reword);
|
||||
|
||||
var squash = new MenuItem();
|
||||
squash.Header = App.Text("CommitCM.Squash");
|
||||
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
|
||||
squash.IsEnabled = commit.Parents.Count == 1;
|
||||
squash.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (commit.Parents.Count == 1)
|
||||
{
|
||||
var parent = _commits.Find(x => x.SHA == commit.Parents[0]);
|
||||
if (parent != null && _repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Squash(_repo, parent, commit.SHA));
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(squash);
|
||||
}
|
||||
|
||||
if (!commit.IsMerged)
|
||||
{
|
||||
var rebase = new MenuItem();
|
||||
rebase.Header = new Views.NameHighlightedTextBlock("CommitCM.Rebase", current.Name);
|
||||
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
|
||||
rebase.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Rebase(_repo, current, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(rebase);
|
||||
|
||||
if (!commit.HasDecorators)
|
||||
{
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("CommitCM.Merge", current.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.Click += (_, e) =>
|
||||
var rebase = new MenuItem();
|
||||
rebase.Header = new Views.NameHighlightedTextBlock("CommitCM.Rebase", current.Name);
|
||||
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
|
||||
rebase.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, commit, current.Name));
|
||||
_repo.ShowPopup(new Rebase(_repo, current, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(rebase);
|
||||
|
||||
if (!commit.HasDecorators)
|
||||
{
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("CommitCM.Merge", current.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, commit, current.Name));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(merge);
|
||||
}
|
||||
|
||||
var cherryPick = new MenuItem();
|
||||
cherryPick.Header = App.Text("CommitCM.CherryPick");
|
||||
cherryPick.Icon = App.CreateMenuIcon("Icons.CherryPick");
|
||||
cherryPick.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
{
|
||||
if (commit.Parents.Count <= 1)
|
||||
{
|
||||
_repo.ShowPopup(new CherryPick(_repo, [commit]));
|
||||
}
|
||||
else
|
||||
{
|
||||
var parents = new List<Models.Commit>();
|
||||
foreach (var sha in commit.Parents)
|
||||
{
|
||||
var parent = _commits.Find(x => x.SHA == sha);
|
||||
if (parent == null)
|
||||
parent = new Commands.QuerySingleCommit(_repo.FullPath, sha).Result();
|
||||
|
||||
if (parent != null)
|
||||
parents.Add(parent);
|
||||
}
|
||||
|
||||
_repo.ShowPopup(new CherryPick(_repo, commit, parents));
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(merge);
|
||||
menu.Items.Add(cherryPick);
|
||||
}
|
||||
else
|
||||
{
|
||||
var revert = new MenuItem();
|
||||
revert.Header = App.Text("CommitCM.Revert");
|
||||
revert.Icon = App.CreateMenuIcon("Icons.Undo");
|
||||
revert.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Revert(_repo, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(revert);
|
||||
}
|
||||
|
||||
var cherryPick = new MenuItem();
|
||||
cherryPick.Header = App.Text("CommitCM.CherryPick");
|
||||
cherryPick.Icon = App.CreateMenuIcon("Icons.CherryPick");
|
||||
cherryPick.Click += (_, e) =>
|
||||
if (current.Head != commit.SHA)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
var checkoutCommit = new MenuItem();
|
||||
checkoutCommit.Header = App.Text("CommitCM.Checkout");
|
||||
checkoutCommit.Icon = App.CreateMenuIcon("Icons.Detached");
|
||||
checkoutCommit.Click += (_, e) =>
|
||||
{
|
||||
if (commit.Parents.Count <= 1)
|
||||
{
|
||||
_repo.ShowPopup(new CherryPick(_repo, [commit]));
|
||||
}
|
||||
else
|
||||
{
|
||||
var parents = new List<Models.Commit>();
|
||||
foreach (var sha in commit.Parents)
|
||||
{
|
||||
var parent = _commits.Find(x => x.SHA == sha);
|
||||
if (parent == null)
|
||||
parent = new Commands.QuerySingleCommit(_repo.FullPath, sha).Result();
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new CheckoutCommit(_repo, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(checkoutCommit);
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
parents.Add(parent);
|
||||
}
|
||||
|
||||
_repo.ShowPopup(new CherryPick(_repo, commit, parents));
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(cherryPick);
|
||||
}
|
||||
else
|
||||
{
|
||||
var revert = new MenuItem();
|
||||
revert.Header = App.Text("CommitCM.Revert");
|
||||
revert.Icon = App.CreateMenuIcon("Icons.Undo");
|
||||
revert.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Revert(_repo, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(revert);
|
||||
}
|
||||
|
||||
if (current.Head != commit.SHA)
|
||||
{
|
||||
var checkoutCommit = new MenuItem();
|
||||
checkoutCommit.Header = App.Text("CommitCM.Checkout");
|
||||
checkoutCommit.Icon = App.CreateMenuIcon("Icons.Detached");
|
||||
checkoutCommit.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new CheckoutCommit(_repo, commit));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(checkoutCommit);
|
||||
}
|
||||
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
if (commit.IsMerged && current.Head != commit.SHA)
|
||||
{
|
||||
var interactiveRebase = new MenuItem();
|
||||
interactiveRebase.Header = new Views.NameHighlightedTextBlock("CommitCM.InteractiveRebase", current.Name);
|
||||
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
|
||||
interactiveRebase.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
App.OpenDialog(new Views.InteractiveRebase()
|
||||
{
|
||||
DataContext = new InteractiveRebase(_repo, current, commit)
|
||||
});
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(interactiveRebase);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
if (commit.IsMerged && current.Head != commit.SHA)
|
||||
{
|
||||
var interactiveRebase = new MenuItem();
|
||||
interactiveRebase.Header = new Views.NameHighlightedTextBlock("CommitCM.InteractiveRebase", current.Name);
|
||||
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
|
||||
interactiveRebase.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.LocalChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
App.OpenDialog(new Views.InteractiveRebase()
|
||||
{
|
||||
DataContext = new InteractiveRebase(_repo, current, commit)
|
||||
});
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(interactiveRebase);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
}
|
||||
|
||||
if (current.Head != commit.SHA)
|
||||
{
|
||||
|
@ -914,21 +920,24 @@ namespace SourceGit.ViewModels
|
|||
submenu.Items.Add(rename);
|
||||
submenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, current.Name);
|
||||
if (detect.IsGitFlowBranch)
|
||||
if (!_repo.IsBare)
|
||||
{
|
||||
var finish = new MenuItem();
|
||||
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", current.Name);
|
||||
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
|
||||
finish.Click += (_, e) =>
|
||||
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, current.Name);
|
||||
if (detect.IsGitFlowBranch)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new GitFlowFinish(_repo, current, detect.Type, detect.Prefix));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(finish);
|
||||
submenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
var finish = new MenuItem();
|
||||
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", current.Name);
|
||||
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
|
||||
finish.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new GitFlowFinish(_repo, current, detect.Type, detect.Prefix));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(finish);
|
||||
submenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
}
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("BranchCM.CopyName");
|
||||
|
@ -951,27 +960,30 @@ namespace SourceGit.ViewModels
|
|||
|
||||
FillBranchVisibilityMenu(submenu, branch);
|
||||
|
||||
var checkout = new MenuItem();
|
||||
checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", branch.Name);
|
||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||
checkout.Click += (_, e) =>
|
||||
if (!_repo.IsBare)
|
||||
{
|
||||
_repo.CheckoutBranch(branch);
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(checkout);
|
||||
var checkout = new MenuItem();
|
||||
checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", branch.Name);
|
||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||
checkout.Click += (_, e) =>
|
||||
{
|
||||
_repo.CheckoutBranch(branch);
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(checkout);
|
||||
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("BranchCM.Merge", branch.Name, current.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.IsEnabled = !merged;
|
||||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, branch, current.Name));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(merge);
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("BranchCM.Merge", branch.Name, current.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.IsEnabled = !merged;
|
||||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, branch, current.Name));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(merge);
|
||||
}
|
||||
|
||||
var rename = new MenuItem();
|
||||
rename.Header = new Views.NameHighlightedTextBlock("BranchCM.Rename", branch.Name);
|
||||
|
@ -996,21 +1008,24 @@ namespace SourceGit.ViewModels
|
|||
submenu.Items.Add(delete);
|
||||
submenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, branch.Name);
|
||||
if (detect.IsGitFlowBranch)
|
||||
if (!_repo.IsBare)
|
||||
{
|
||||
var finish = new MenuItem();
|
||||
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", branch.Name);
|
||||
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
|
||||
finish.Click += (_, e) =>
|
||||
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, branch.Name);
|
||||
if (detect.IsGitFlowBranch)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new GitFlowFinish(_repo, branch, detect.Type, detect.Prefix));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(finish);
|
||||
submenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
var finish = new MenuItem();
|
||||
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", branch.Name);
|
||||
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
|
||||
finish.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new GitFlowFinish(_repo, branch, detect.Type, detect.Prefix));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(finish);
|
||||
submenu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
}
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("BranchCM.CopyName");
|
||||
|
@ -1104,17 +1119,19 @@ namespace SourceGit.ViewModels
|
|||
};
|
||||
submenu.Items.Add(push);
|
||||
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("TagCM.Merge", tag.Name, current.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.IsEnabled = !merged;
|
||||
merge.Click += (_, e) =>
|
||||
if (!_repo.IsBare && !merged)
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, tag, current.Name));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(merge);
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("TagCM.Merge", tag.Name, current.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, tag, current.Name));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(merge);
|
||||
}
|
||||
|
||||
var delete = new MenuItem();
|
||||
delete.Header = new Views.NameHighlightedTextBlock("TagCM.Delete", tag.Name);
|
||||
|
|
|
@ -1434,66 +1434,72 @@ namespace SourceGit.ViewModels
|
|||
|
||||
if (branch.IsCurrent)
|
||||
{
|
||||
var discard = new MenuItem();
|
||||
discard.Header = App.Text("BranchCM.DiscardAll");
|
||||
discard.Icon = App.CreateMenuIcon("Icons.Undo");
|
||||
discard.Click += (_, e) =>
|
||||
if (!IsBare)
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Discard(this));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(discard);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
if (!string.IsNullOrEmpty(branch.Upstream))
|
||||
{
|
||||
var upstream = branch.Upstream.Substring(13);
|
||||
var fastForward = new MenuItem();
|
||||
fastForward.Header = new Views.NameHighlightedTextBlock("BranchCM.FastForward", upstream);
|
||||
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
|
||||
fastForward.IsEnabled = branch.TrackStatus.Ahead.Count == 0;
|
||||
fastForward.Click += (_, e) =>
|
||||
var discard = new MenuItem();
|
||||
discard.Header = App.Text("BranchCM.DiscardAll");
|
||||
discard.Icon = App.CreateMenuIcon("Icons.Undo");
|
||||
discard.Click += (_, e) =>
|
||||
{
|
||||
var b = _branches.Find(x => x.FriendlyName == upstream);
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
if (CanCreatePopup())
|
||||
ShowAndStartPopup(new Merge(this, b, branch.Name));
|
||||
|
||||
ShowPopup(new Discard(this));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var pull = new MenuItem();
|
||||
pull.Header = new Views.NameHighlightedTextBlock("BranchCM.Pull", upstream);
|
||||
pull.Icon = App.CreateMenuIcon("Icons.Pull");
|
||||
pull.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Pull(this, null));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(discard);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
menu.Items.Add(fastForward);
|
||||
menu.Items.Add(pull);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(branch.Upstream))
|
||||
{
|
||||
var upstream = branch.Upstream.Substring(13);
|
||||
var fastForward = new MenuItem();
|
||||
fastForward.Header = new Views.NameHighlightedTextBlock("BranchCM.FastForward", upstream);
|
||||
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
|
||||
fastForward.IsEnabled = branch.TrackStatus.Ahead.Count == 0;
|
||||
fastForward.Click += (_, e) =>
|
||||
{
|
||||
var b = _branches.Find(x => x.FriendlyName == upstream);
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
if (CanCreatePopup())
|
||||
ShowAndStartPopup(new Merge(this, b, branch.Name));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var pull = new MenuItem();
|
||||
pull.Header = new Views.NameHighlightedTextBlock("BranchCM.Pull", upstream);
|
||||
pull.Icon = App.CreateMenuIcon("Icons.Pull");
|
||||
pull.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Pull(this, null));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(fastForward);
|
||||
menu.Items.Add(pull);
|
||||
}
|
||||
}
|
||||
|
||||
menu.Items.Add(push);
|
||||
}
|
||||
else
|
||||
{
|
||||
var checkout = new MenuItem();
|
||||
checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", branch.Name);
|
||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||
checkout.Click += (_, e) =>
|
||||
if (!IsBare)
|
||||
{
|
||||
CheckoutBranch(branch);
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(checkout);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
var checkout = new MenuItem();
|
||||
checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", branch.Name);
|
||||
checkout.Icon = App.CreateMenuIcon("Icons.Check");
|
||||
checkout.Click += (_, e) =>
|
||||
{
|
||||
CheckoutBranch(branch);
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(checkout);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
var worktree = _worktrees.Find(x => x.Branch == branch.FullName);
|
||||
var upstream = _branches.Find(x => x.FullName == branch.Upstream);
|
||||
|
@ -1528,28 +1534,31 @@ namespace SourceGit.ViewModels
|
|||
|
||||
menu.Items.Add(push);
|
||||
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("BranchCM.Merge", branch.Name, _currentBranch.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.Click += (_, e) =>
|
||||
if (!IsBare)
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Merge(this, branch, _currentBranch.Name));
|
||||
e.Handled = true;
|
||||
};
|
||||
var merge = new MenuItem();
|
||||
merge.Header = new Views.NameHighlightedTextBlock("BranchCM.Merge", branch.Name, _currentBranch.Name);
|
||||
merge.Icon = App.CreateMenuIcon("Icons.Merge");
|
||||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Merge(this, branch, _currentBranch.Name));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var rebase = new MenuItem();
|
||||
rebase.Header = new Views.NameHighlightedTextBlock("BranchCM.Rebase", _currentBranch.Name, branch.Name);
|
||||
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
|
||||
rebase.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Rebase(this, _currentBranch, branch));
|
||||
e.Handled = true;
|
||||
};
|
||||
var rebase = new MenuItem();
|
||||
rebase.Header = new Views.NameHighlightedTextBlock("BranchCM.Rebase", _currentBranch.Name, branch.Name);
|
||||
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
|
||||
rebase.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Rebase(this, _currentBranch, branch));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(merge);
|
||||
menu.Items.Add(rebase);
|
||||
menu.Items.Add(merge);
|
||||
menu.Items.Add(rebase);
|
||||
}
|
||||
|
||||
var compareWithHead = new MenuItem();
|
||||
compareWithHead.Header = App.Text("BranchCM.CompareWithHead");
|
||||
|
@ -1584,21 +1593,24 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
var detect = Commands.GitFlow.DetectType(_fullpath, _branches, branch.Name);
|
||||
if (detect.IsGitFlowBranch)
|
||||
if (!IsBare)
|
||||
{
|
||||
var finish = new MenuItem();
|
||||
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", branch.Name);
|
||||
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
|
||||
finish.Click += (_, e) =>
|
||||
var detect = Commands.GitFlow.DetectType(_fullpath, _branches, branch.Name);
|
||||
if (detect.IsGitFlowBranch)
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new GitFlowFinish(this, branch, detect.Type, detect.Prefix));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(finish);
|
||||
}
|
||||
var finish = new MenuItem();
|
||||
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", branch.Name);
|
||||
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
|
||||
finish.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new GitFlowFinish(this, branch, detect.Type, detect.Prefix));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(finish);
|
||||
}
|
||||
}
|
||||
|
||||
var rename = new MenuItem();
|
||||
rename.Header = new Views.NameHighlightedTextBlock("BranchCM.Rename", branch.Name);
|
||||
|
@ -1649,26 +1661,29 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(createTag);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
var remoteBranches = new List<Models.Branch>();
|
||||
foreach (var b in _branches)
|
||||
if (!IsBare)
|
||||
{
|
||||
if (!b.IsLocal)
|
||||
remoteBranches.Add(b);
|
||||
}
|
||||
|
||||
if (remoteBranches.Count > 0)
|
||||
{
|
||||
var tracking = new MenuItem();
|
||||
tracking.Header = App.Text("BranchCM.Tracking");
|
||||
tracking.Icon = App.CreateMenuIcon("Icons.Track");
|
||||
tracking.Click += (_, e) =>
|
||||
var remoteBranches = new List<Models.Branch>();
|
||||
foreach (var b in _branches)
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new SetUpstream(this, branch, remoteBranches));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(tracking);
|
||||
}
|
||||
if (!b.IsLocal)
|
||||
remoteBranches.Add(b);
|
||||
}
|
||||
|
||||
if (remoteBranches.Count > 0)
|
||||
{
|
||||
var tracking = new MenuItem();
|
||||
tracking.Header = App.Text("BranchCM.Tracking");
|
||||
tracking.Icon = App.CreateMenuIcon("Icons.Track");
|
||||
tracking.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new SetUpstream(this, branch, remoteBranches));
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(tracking);
|
||||
}
|
||||
}
|
||||
|
||||
var archive = new MenuItem();
|
||||
archive.Icon = App.CreateMenuIcon("Icons.Archive");
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<Path Width="14" Height="14" Data="{StaticResource Icons.Explore}" Margin="0,2,0,0"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
||||
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" IsVisible="{Binding !IsBare}" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
||||
</Button>
|
||||
|
||||
|
|
Loading…
Reference in a new issue