From e1b4d625c7d7d11bea1a42c6fe5fea3ff2a9e415 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 19 May 2024 17:10:34 +0200 Subject: [PATCH] Make parseDiff a non-member function so that we can test it more easily --- pkg/gui/controllers/helpers/fixup_helper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/gui/controllers/helpers/fixup_helper.go b/pkg/gui/controllers/helpers/fixup_helper.go index e50389e90..e8fe1d2f2 100644 --- a/pkg/gui/controllers/helpers/fixup_helper.go +++ b/pkg/gui/controllers/helpers/fixup_helper.go @@ -41,7 +41,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error { return errors.New(self.c.Tr.NoChangedFiles) } - deletedLineHunks, hasHunksWithOnlyAddedLines := self.parseDiff(diff) + deletedLineHunks, hasHunksWithOnlyAddedLines := parseDiff(diff) if len(deletedLineHunks) == 0 { return errors.New(self.c.Tr.NoDeletedLinesInDiff) } @@ -122,7 +122,7 @@ func (self *FixupHelper) getDiff() (string, bool, error) { return diff, hasStagedChanges, err } -func (self *FixupHelper) parseDiff(diff string) ([]*hunk, bool) { +func parseDiff(diff string) ([]*hunk, bool) { lines := strings.Split(strings.TrimSuffix(diff, "\n"), "\n") deletedLineHunks := []*hunk{}