From 8e2ed8c5381a1ae7ddbf155e09d9e5e8cde0090c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 28 Aug 2024 16:35:03 +0200 Subject: [PATCH] Extract helper function currentFromToReverseForPatchBuilding In the next commit it will be reused for checking whether we need to reset the patch; and extracting it makes it easier to extend it for non-sticky diff ranges later in the branch. --- pkg/gui/controllers/commits_files_controller.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 2a9ba8271..8091468a7 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -330,14 +330,21 @@ func (self *CommitFilesController) startPatchBuilder() error { commitFilesContext := self.context() canRebase := commitFilesContext.GetCanRebase() - ref := commitFilesContext.GetRef() - to := ref.RefName() - from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) + from, to, reverse := self.currentFromToReverseForPatchBuilding() self.c.Git().Patch.PatchBuilder.Start(from, to, reverse, canRebase) return nil } +func (self *CommitFilesController) currentFromToReverseForPatchBuilding() (string, string, bool) { + commitFilesContext := self.context() + + ref := commitFilesContext.GetRef() + to := ref.RefName() + from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName()) + return from, to, reverse +} + func (self *CommitFilesController) enter(node *filetree.CommitFileNode) error { return self.enterCommitFile(node, types.OnFocusOpts{ClickedWindowName: "", ClickedViewLineIdx: -1}) }