Skip to content

Commit 19f8829

Browse files
committed
Change allBranchesLogCmdIndex to an int
I know that uint was chosen to document that it can't be negative (not sure why the "8" was chosen, though). That's pointless in languages that don't enforce this though: you can subtract 1 from uint8(0) and you'll get something that doesn't make sense; that's not any better than getting -1. I'm not a fan of using unsigned types in general (at least in languages like go or C++), and they usually just make the code more cumbersome without real benefits.
1 parent 47ca082 commit 19f8829

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/commands/git_commands/branch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
type BranchCommands struct {
1515
*GitCommon
16-
allBranchesLogCmdIndex uint8 // keeps track of current all branches log command
16+
allBranchesLogCmdIndex int // keeps track of current all branches log command
1717
}
1818

1919
func NewBranchCommands(gitCommon *GitCommon) *BranchCommands {
@@ -285,7 +285,7 @@ func (self *BranchCommands) AllBranchesLogCmdObj() *oscommands.CmdObj {
285285
func (self *BranchCommands) RotateAllBranchesLogIdx() {
286286
n := len(self.allBranchesLogCandidates())
287287
i := self.allBranchesLogCmdIndex
288-
self.allBranchesLogCmdIndex = uint8((int(i) + 1) % n)
288+
self.allBranchesLogCmdIndex = (i + 1) % n
289289
}
290290

291291
func (self *BranchCommands) IsBranchMerged(branch *models.Branch, mainBranches *MainBranches) (bool, error) {

0 commit comments

Comments
 (0)