diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-24 18:14:49 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-24 20:14:41 +1100 |
commit | cf74c2cf96ea99e195f82c0864daadaad2c09d17 (patch) | |
tree | a83c5730f67271ccf818d6a7152a9880966bda8a | |
parent | 43d3f2bcb6094293156841f6670577720bab2314 (diff) |
reorder
-rw-r--r-- | pkg/commands/loaders/branches.go | 52 |
1 files changed, 26 insertions, 26 deletions
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 { |