Remove canUsePushTrack parameter of obtainBranches function

It was only needed for git versions older than 2.22.
This commit is contained in:
Stefan Haller 2025-03-31 15:55:01 +02:00
parent ad813503fb
commit 765168b9d7
2 changed files with 6 additions and 11 deletions

View file

@ -72,7 +72,7 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit,
onWorker func(func() error), onWorker func(func() error),
renderFunc func(), renderFunc func(),
) ([]*models.Branch, error) { ) ([]*models.Branch, error) {
branches := self.obtainBranches(self.version.IsAtLeast(2, 22, 0)) branches := self.obtainBranches()
if self.AppState.LocalBranchSortOrder == "recency" { if self.AppState.LocalBranchSortOrder == "recency" {
reflogBranches := self.obtainReflogBranches(reflogCommits) reflogBranches := self.obtainReflogBranches(reflogCommits)
@ -232,7 +232,7 @@ func (self *BranchLoader) GetBaseBranch(branch *models.Branch, mainBranches *Mai
return split[0], nil return split[0], nil
} }
func (self *BranchLoader) obtainBranches(canUsePushTrack bool) []*models.Branch { func (self *BranchLoader) obtainBranches() []*models.Branch {
output, err := self.getRawBranches() output, err := self.getRawBranches()
if err != nil { if err != nil {
panic(err) panic(err)
@ -255,7 +255,7 @@ func (self *BranchLoader) obtainBranches(canUsePushTrack bool) []*models.Branch
} }
storeCommitDateAsRecency := self.AppState.LocalBranchSortOrder != "recency" storeCommitDateAsRecency := self.AppState.LocalBranchSortOrder != "recency"
return obtainBranch(split, storeCommitDateAsRecency, canUsePushTrack), true return obtainBranch(split, storeCommitDateAsRecency), true
}) })
} }
@ -298,7 +298,7 @@ var branchFields = []string{
} }
// Obtain branch information from parsed line output of getRawBranches() // Obtain branch information from parsed line output of getRawBranches()
func obtainBranch(split []string, storeCommitDateAsRecency bool, canUsePushTrack bool) *models.Branch { func obtainBranch(split []string, storeCommitDateAsRecency bool) *models.Branch {
headMarker := split[0] headMarker := split[0]
fullName := split[1] fullName := split[1]
upstreamName := split[2] upstreamName := split[2]
@ -310,12 +310,7 @@ func obtainBranch(split []string, storeCommitDateAsRecency bool, canUsePushTrack
name := strings.TrimPrefix(fullName, "heads/") name := strings.TrimPrefix(fullName, "heads/")
aheadForPull, behindForPull, gone := parseUpstreamInfo(upstreamName, track) aheadForPull, behindForPull, gone := parseUpstreamInfo(upstreamName, track)
var aheadForPush, behindForPush string aheadForPush, behindForPush, _ := parseUpstreamInfo(upstreamName, pushTrack)
if canUsePushTrack {
aheadForPush, behindForPush, _ = parseUpstreamInfo(upstreamName, pushTrack)
} else {
aheadForPush, behindForPush = aheadForPull, behindForPull
}
recency := "" recency := ""
if storeCommitDateAsRecency { if storeCommitDateAsRecency {

View file

@ -119,7 +119,7 @@ func TestObtainBranch(t *testing.T) {
for _, s := range scenarios { for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) { t.Run(s.testName, func(t *testing.T) {
branch := obtainBranch(s.input, s.storeCommitDateAsRecency, true) branch := obtainBranch(s.input, s.storeCommitDateAsRecency)
assert.EqualValues(t, s.expectedBranch, branch) assert.EqualValues(t, s.expectedBranch, branch)
}) })
} }