rename sha to hash 2

This commit is contained in:
pikomonde 2024-03-21 00:45:04 +07:00 committed by Stefan Haller
parent e6ef1642fa
commit 92aab21d3a
5 changed files with 21 additions and 21 deletions

View file

@ -143,7 +143,7 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
return false, nil, nil return false, nil, nil
} }
newSha := info.GetNewSha() newSha := info.GetNewHash()
if newSha == "" { if newSha == "" {
return false, nil, nil return false, nil, nil
} }
@ -185,7 +185,7 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
// render the commits from the bad commit. // render the commits from the bad commit.
func (self *BisectCommands) ReachableFromStart(bisectInfo *BisectInfo) bool { func (self *BisectCommands) ReachableFromStart(bisectInfo *BisectInfo) bool {
cmdArgs := NewGitCmd("merge-base"). cmdArgs := NewGitCmd("merge-base").
Arg("--is-ancestor", bisectInfo.GetNewSha(), bisectInfo.GetStartSha()). Arg("--is-ancestor", bisectInfo.GetNewHash(), bisectInfo.GetStartHash()).
ToArgv() ToArgv()
err := self.cmd.New(cmdArgs).DontLog().Run() err := self.cmd.New(cmdArgs).DontLog().Run()

View file

@ -32,7 +32,7 @@ type BisectInfo struct {
// map of commit hashes to their status // map of commit hashes to their status
statusMap map[string]BisectStatus statusMap map[string]BisectStatus
// the sha of the commit that's under test // the hash of the commit that's under test
current string current string
} }
@ -49,21 +49,21 @@ func NewNullBisectInfo() *BisectInfo {
return &BisectInfo{started: false} return &BisectInfo{started: false}
} }
func (self *BisectInfo) GetNewSha() string { func (self *BisectInfo) GetNewHash() string {
for sha, status := range self.statusMap { for hash, status := range self.statusMap {
if status == BisectStatusNew { if status == BisectStatusNew {
return sha return hash
} }
} }
return "" return ""
} }
func (self *BisectInfo) GetCurrentSha() string { func (self *BisectInfo) GetCurrentHash() string {
return self.current return self.current
} }
func (self *BisectInfo) GetStartSha() string { func (self *BisectInfo) GetStartHash() string {
return self.start return self.start
} }
@ -93,7 +93,7 @@ func (self *BisectInfo) Bisecting() bool {
return false return false
} }
if self.GetNewSha() == "" { if self.GetNewHash() == "" {
return false return false
} }

View file

@ -69,7 +69,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
// Originally we were allowing the user to, from the bisect menu, select whether // Originally we were allowing the user to, from the bisect menu, select whether
// they were talking about the selected commit or the current bisect commit, // they were talking about the selected commit or the current bisect commit,
// and that was a bit confusing (and required extra keypresses). // and that was a bit confusing (and required extra keypresses).
selectCurrentAfter := info.GetCurrentSha() == "" || info.GetCurrentSha() == commit.Hash selectCurrentAfter := info.GetCurrentHash() == "" || info.GetCurrentHash() == commit.Hash
// we need to wait to reselect if our bisect commits aren't ancestors of our 'start' // we need to wait to reselect if our bisect commits aren't ancestors of our 'start'
// ref, because we'll be reloading our commits in that case. // ref, because we'll be reloading our commits in that case.
waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info) waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info)
@ -78,8 +78,8 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
// not, we're still picking the initial commits before we really start, so // not, we're still picking the initial commits before we really start, so
// use the selected commit in that case. // use the selected commit in that case.
bisecting := info.GetCurrentSha() != "" bisecting := info.GetCurrentHash() != ""
shaToMark := lo.Ternary(bisecting, info.GetCurrentSha(), commit.Hash) shaToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash)
shortShaToMark := utils.ShortSha(shaToMark) shortShaToMark := utils.ShortSha(shaToMark)
// For marking a commit as bad, when we're not already bisecting, we require // For marking a commit as bad, when we're not already bisecting, we require
@ -131,7 +131,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 's', Key: 's',
}, },
} }
if info.GetCurrentSha() != "" && info.GetCurrentSha() != commit.Hash { if info.GetCurrentHash() != "" && info.GetCurrentHash() != commit.Hash {
menuItems = append(menuItems, lo.ToPtr(types.MenuItem{ menuItems = append(menuItems, lo.ToPtr(types.MenuItem{
Label: fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, commit.ShortSha()), Label: fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, commit.ShortSha()),
OnPress: func() error { OnPress: func() error {
@ -284,10 +284,10 @@ func (self *BisectController) afterBisectMarkRefresh(selectCurrent bool, waitToR
func (self *BisectController) selectCurrentBisectCommit() { func (self *BisectController) selectCurrentBisectCommit() {
info := self.c.Git().Bisect.GetInfo() info := self.c.Git().Bisect.GetInfo()
if info.GetCurrentSha() != "" { if info.GetCurrentHash() != "" {
// find index of commit with that sha, move cursor to that. // find index of commit with that sha, move cursor to that.
for i, commit := range self.c.Model().Commits { for i, commit := range self.c.Model().Commits {
if commit.Hash == info.GetCurrentSha() { if commit.Hash == info.GetCurrentHash() {
self.context().SetSelection(i) self.context().SetSelection(i)
_ = self.context().HandleFocus(types.OnFocusOpts{}) _ = self.context().HandleFocus(types.OnFocusOpts{})
break break

View file

@ -290,10 +290,10 @@ func (self *RefreshHelper) determineCheckedOutBranchName() string {
return strings.TrimPrefix(rebasedBranch, "refs/heads/") return strings.TrimPrefix(rebasedBranch, "refs/heads/")
} }
if bisectInfo := self.c.Git().Bisect.GetInfo(); bisectInfo.Bisecting() && bisectInfo.GetStartSha() != "" { if bisectInfo := self.c.Git().Bisect.GetInfo(); bisectInfo.Bisecting() && bisectInfo.GetStartHash() != "" {
// Likewise, when we're bisecting we're on a detached head as well. In // Likewise, when we're bisecting we're on a detached head as well. In
// this case we read the branch name from the ".git/BISECT_START" file. // this case we read the branch name from the ".git/BISECT_START" file.
return bisectInfo.GetStartSha() return bisectInfo.GetStartHash()
} }
// In all other cases, get the branch name by asking git what branch is // In all other cases, get the branch name by asking git what branch is
@ -721,10 +721,10 @@ func (self *RefreshHelper) refForLog() string {
// need to see if our bisect's current commit is reachable from our 'new' ref. // need to see if our bisect's current commit is reachable from our 'new' ref.
if bisectInfo.Bisecting() && !self.c.Git().Bisect.ReachableFromStart(bisectInfo) { if bisectInfo.Bisecting() && !self.c.Git().Bisect.ReachableFromStart(bisectInfo) {
return bisectInfo.GetNewSha() return bisectInfo.GetNewHash()
} }
return bisectInfo.GetStartSha() return bisectInfo.GetStartHash()
} }
func (self *RefreshHelper) refreshView(context types.Context) error { func (self *RefreshHelper) refreshView(context types.Context) error {

View file

@ -172,7 +172,7 @@ func getbisectBounds(commits []*models.Commit, bisectInfo *git_commands.BisectIn
bisectBounds := &bisectBounds{} bisectBounds := &bisectBounds{}
for i, commit := range commits { for i, commit := range commits {
if commit.Hash == bisectInfo.GetNewSha() { if commit.Hash == bisectInfo.GetNewHash() {
bisectBounds.newIndex = i bisectBounds.newIndex = i
} }
@ -241,7 +241,7 @@ func getBisectStatus(index int, commitHash string, bisectInfo *git_commands.Bise
return BisectStatusNone return BisectStatusNone
} }
if bisectInfo.GetCurrentSha() == commitHash { if bisectInfo.GetCurrentHash() == commitHash {
return BisectStatusCurrent return BisectStatusCurrent
} }