From 7891b1124e7a94173d7093fc3aa6f548f06806bc Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 1 Aug 2024 16:59:39 +0800 Subject: [PATCH] feature: asking to create local branch instead of checkout commit if some remote branch's HEAD is selected commit (#295) --- src/ViewModels/Histories.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 9ec3a897..caeba32f 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -147,6 +147,7 @@ namespace SourceGit.ViewModels if (commit == null || commit.IsCurrentHead) return; + var firstRemoteBranch = null as Models.Branch; foreach (var d in commit.Decorators) { if (d.Type == Models.DecoratorType.LocalBranchHead) @@ -158,10 +159,19 @@ namespace SourceGit.ViewModels return; } } + else if (d.Type == Models.DecoratorType.RemoteBranchHead && firstRemoteBranch == null) + { + firstRemoteBranch = _repo.Branches.Find(x => x.FriendlyName == d.Name); + } } if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new CheckoutCommit(_repo, commit)); + { + if (firstRemoteBranch != null) + PopupHost.ShowPopup(new CreateBranch(_repo, firstRemoteBranch)); + else + PopupHost.ShowPopup(new CheckoutCommit(_repo, commit)); + } } public ContextMenu MakeContextMenu(DataGrid datagrid)