From cf74c2cf96ea99e195f82c0864daadaad2c09d17 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Thu, 24 Mar 2022 18:14:49 +1100 Subject: reorder --- pkg/commands/loaders/branches.go | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'pkg/commands') diff --git a/pkg/commands/loaders/branches.go b/pkg/commands/loaders/branches.go index 682c23ad4..f9e5c052b 100644 --- a/pkg/commands/loaders/branches.go +++ b/pkg/commands/loaders/branches.go @@ -107,6 +107,32 @@ outer: return branches, nil } +func (self *BranchLoader) obtainBranches() []*models.Branch { + output, err := self.getRawBranches() + if err != nil { + panic(err) + } + + trimmedOutput := strings.TrimSpace(output) + outputLines := strings.Split(trimmedOutput, "\n") + + return slices.FilterMap(outputLines, func(line string) (*models.Branch, bool) { + if line == "" { + return nil, false + } + + split := strings.Split(line, SEPARATION_CHAR) + if len(split) != 4 { + // Ignore line if it isn't separated into 4 parts + // This is probably a warning message, for more info see: + // https://github.com/jesseduffield/lazygit/issues/1385#issuecomment-885580439 + return nil, false + } + + return obtainBranch(split), true + }) +} + // Obtain branch information from parsed line output of getRawBranches() // split contains the '|' separated tokens in the line of output func obtainBranch(split []string) *models.Branch { @@ -150,32 +176,6 @@ func obtainBranch(split []string) *models.Branch { return branch } -func (self *BranchLoader) obtainBranches() []*models.Branch { - output, err := self.getRawBranches() - if err != nil { - panic(err) - } - - trimmedOutput := strings.TrimSpace(output) - outputLines := strings.Split(trimmedOutput, "\n") - - return slices.FilterMap(outputLines, func(line string) (*models.Branch, bool) { - if line == "" { - return nil, false - } - - split := strings.Split(line, SEPARATION_CHAR) - if len(split) != 4 { - // Ignore line if it isn't separated into 4 parts - // This is probably a warning message, for more info see: - // https://github.com/jesseduffield/lazygit/issues/1385#issuecomment-885580439 - return nil, false - } - - return obtainBranch(split), true - }) -} - // TODO: only look at the new reflog commits, and otherwise store the recencies in // int form against the branch to recalculate the time ago func (self *BranchLoader) obtainReflogBranches(reflogCommits []*models.Commit) []*models.Branch { -- cgit v1.2.3