Skip to content

Commit 765168b

Browse files
committed
Remove canUsePushTrack parameter of obtainBranches function
It was only needed for git versions older than 2.22.
1 parent ad81350 commit 765168b

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

pkg/commands/git_commands/branch_loader.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit,
7272
onWorker func(func() error),
7373
renderFunc func(),
7474
) ([]*models.Branch, error) {
75-
branches := self.obtainBranches(self.version.IsAtLeast(2, 22, 0))
75+
branches := self.obtainBranches()
7676

7777
if self.AppState.LocalBranchSortOrder == "recency" {
7878
reflogBranches := self.obtainReflogBranches(reflogCommits)
@@ -232,7 +232,7 @@ func (self *BranchLoader) GetBaseBranch(branch *models.Branch, mainBranches *Mai
232232
return split[0], nil
233233
}
234234

235-
func (self *BranchLoader) obtainBranches(canUsePushTrack bool) []*models.Branch {
235+
func (self *BranchLoader) obtainBranches() []*models.Branch {
236236
output, err := self.getRawBranches()
237237
if err != nil {
238238
panic(err)
@@ -255,7 +255,7 @@ func (self *BranchLoader) obtainBranches(canUsePushTrack bool) []*models.Branch
255255
}
256256

257257
storeCommitDateAsRecency := self.AppState.LocalBranchSortOrder != "recency"
258-
return obtainBranch(split, storeCommitDateAsRecency, canUsePushTrack), true
258+
return obtainBranch(split, storeCommitDateAsRecency), true
259259
})
260260
}
261261

@@ -298,7 +298,7 @@ var branchFields = []string{
298298
}
299299

300300
// Obtain branch information from parsed line output of getRawBranches()
301-
func obtainBranch(split []string, storeCommitDateAsRecency bool, canUsePushTrack bool) *models.Branch {
301+
func obtainBranch(split []string, storeCommitDateAsRecency bool) *models.Branch {
302302
headMarker := split[0]
303303
fullName := split[1]
304304
upstreamName := split[2]
@@ -310,12 +310,7 @@ func obtainBranch(split []string, storeCommitDateAsRecency bool, canUsePushTrack
310310

311311
name := strings.TrimPrefix(fullName, "heads/")
312312
aheadForPull, behindForPull, gone := parseUpstreamInfo(upstreamName, track)
313-
var aheadForPush, behindForPush string
314-
if canUsePushTrack {
315-
aheadForPush, behindForPush, _ = parseUpstreamInfo(upstreamName, pushTrack)
316-
} else {
317-
aheadForPush, behindForPush = aheadForPull, behindForPull
318-
}
313+
aheadForPush, behindForPush, _ := parseUpstreamInfo(upstreamName, pushTrack)
319314

320315
recency := ""
321316
if storeCommitDateAsRecency {

pkg/commands/git_commands/branch_loader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestObtainBranch(t *testing.T) {
119119

120120
for _, s := range scenarios {
121121
t.Run(s.testName, func(t *testing.T) {
122-
branch := obtainBranch(s.input, s.storeCommitDateAsRecency, true)
122+
branch := obtainBranch(s.input, s.storeCommitDateAsRecency)
123123
assert.EqualValues(t, s.expectedBranch, branch)
124124
})
125125
}

0 commit comments

Comments
 (0)