rename sha to hash 6, update short hash

This commit is contained in:
pikomonde 2024-03-21 01:59:00 +07:00 committed by Stefan Haller
parent 9cf1ca10a2
commit 05fb12b1d5
11 changed files with 16 additions and 16 deletions

View file

@ -263,7 +263,7 @@ func mergeBuildInfo(buildInfo *BuildInfo) {
buildInfo.Commit = revision.Value buildInfo.Commit = revision.Value
// if lazygit was built from source we'll show the version as the // if lazygit was built from source we'll show the version as the
// abbreviated commit hash // abbreviated commit hash
buildInfo.Version = utils.ShortSha(revision.Value) buildInfo.Version = utils.ShortHash(revision.Value)
} }
// if version hasn't been set we assume that neither has the date // if version hasn't been set we assume that neither has the date

View file

@ -506,7 +506,7 @@ func (self *RebaseCommands) DiscardOldFileChanges(commits []*models.Commit, comm
// CherryPickCommits begins an interactive rebase with the given shas being cherry picked onto HEAD // CherryPickCommits begins an interactive rebase with the given shas being cherry picked onto HEAD
func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error { func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error {
commitLines := lo.Map(commits, func(commit *models.Commit, _ int) string { commitLines := lo.Map(commits, func(commit *models.Commit, _ int) string {
return fmt.Sprintf("%s %s", utils.ShortSha(commit.Hash), commit.Name) return fmt.Sprintf("%s %s", utils.ShortHash(commit.Hash), commit.Name)
}) })
msg := utils.ResolvePlaceholderString( msg := utils.ResolvePlaceholderString(
self.Tr.Log.CherryPickCommits, self.Tr.Log.CherryPickCommits,

View file

@ -58,8 +58,8 @@ type Commit struct {
Parents []string Parents []string
} }
func (c *Commit) ShortSha() string { func (c *Commit) ShortHash() string {
return utils.ShortSha(c.Hash) return utils.ShortHash(c.Hash)
} }
func (c *Commit) FullRefName() string { func (c *Commit) FullRefName() string {

View file

@ -22,7 +22,7 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
viewModel := NewFilteredListViewModel( viewModel := NewFilteredListViewModel(
func() []*models.Commit { return c.Model().FilteredReflogCommits }, func() []*models.Commit { return c.Model().FilteredReflogCommits },
func(commit *models.Commit) []string { func(commit *models.Commit) []string {
return []string{commit.ShortSha(), commit.Name} return []string{commit.ShortHash(), commit.Name}
}, },
) )

View file

@ -80,7 +80,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
bisecting := info.GetCurrentHash() != "" bisecting := info.GetCurrentHash() != ""
shaToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash) shaToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash)
shortShaToMark := utils.ShortSha(shaToMark) shortShaToMark := utils.ShortHash(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
// a single item selected, but once we are bisecting, it doesn't matter because // a single item selected, but once we are bisecting, it doesn't matter because
@ -133,7 +133,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
} }
if info.GetCurrentHash() != "" && info.GetCurrentHash() != 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.ShortHash()),
OnPress: func() error { OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectSkip) self.c.LogAction(self.c.Tr.Actions.BisectSkip)
if err := self.c.Git().Bisect.Skip(commit.Hash); err != nil { if err := self.c.Git().Bisect.Skip(commit.Hash); err != nil {
@ -165,7 +165,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
Title: self.c.Tr.Bisect.BisectMenuTitle, Title: self.c.Tr.Bisect.BisectMenuTitle,
Items: []*types.MenuItem{ Items: []*types.MenuItem{
{ {
Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()), Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortHash(), info.NewTerm()),
OnPress: func() error { OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.StartBisect) self.c.LogAction(self.c.Tr.Actions.StartBisect)
if err := self.c.Git().Bisect.Start(); err != nil { if err := self.c.Git().Bisect.Start(); err != nil {
@ -182,7 +182,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
Key: 'b', Key: 'b',
}, },
{ {
Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()), Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortHash(), info.OldTerm()),
OnPress: func() error { OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.StartBisect) self.c.LogAction(self.c.Tr.Actions.StartBisect)
if err := self.c.Git().Bisect.Start(); err != nil { if err := self.c.Git().Bisect.Start(); err != nil {

View file

@ -63,7 +63,7 @@ func (self *ReposHelper) getCurrentBranch(path string) string {
branchDisplay = strings.TrimPrefix(content, refsPrefix) branchDisplay = strings.TrimPrefix(content, refsPrefix)
} else { } else {
// detached HEAD state, displaying short SHA // detached HEAD state, displaying short SHA
branchDisplay = utils.ShortSha(content) branchDisplay = utils.ShortHash(content)
} }
return branchDisplay, nil return branchDisplay, nil
} }

View file

@ -782,7 +782,7 @@ func (self *LocalCommitsController) revert(commit *models.Commit) error {
Prompt: utils.ResolvePlaceholderString( Prompt: utils.ResolvePlaceholderString(
self.c.Tr.ConfirmRevertCommit, self.c.Tr.ConfirmRevertCommit,
map[string]string{ map[string]string{
"selectedCommit": commit.ShortSha(), "selectedCommit": commit.ShortHash(),
}), }),
HandleConfirm: func() error { HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.RevertCommit) self.c.LogAction(self.c.Tr.Actions.RevertCommit)

View file

@ -106,7 +106,7 @@ func getBranchDisplayStrings(
} }
if showCommitHash { if showCommitHash {
res = append(res, utils.ShortSha(b.CommitHash)) res = append(res, utils.ShortHash(b.CommitHash))
} }
res = append(res, coloredName) res = append(res, coloredName)

View file

@ -373,7 +373,7 @@ func displayCommit(
} else if icons.IsIconEnabled() { } else if icons.IsIconEnabled() {
cols = append(cols, shaColor.Sprint(icons.IconForCommit(commit))) cols = append(cols, shaColor.Sprint(icons.IconForCommit(commit)))
} }
cols = append(cols, shaColor.Sprint(commit.ShortSha())) cols = append(cols, shaColor.Sprint(commit.ShortHash()))
cols = append(cols, bisectString) cols = append(cols, bisectString)
if fullDescription { if fullDescription {
cols = append(cols, style.FgBlue.Sprint( cols = append(cols, style.FgBlue.Sprint(

View file

@ -64,7 +64,7 @@ func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, attrs ref
} }
return []string{ return []string{
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()), reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()),
style.FgMagenta.Sprint(utils.UnixToDateSmart(attrs.now, c.UnixTimestamp, attrs.timeFormat, attrs.shortTimeFormat)), style.FgMagenta.Sprint(utils.UnixToDateSmart(attrs.now, c.UnixTimestamp, attrs.timeFormat, attrs.shortTimeFormat)),
theme.DefaultTextColor.Sprint(name), theme.DefaultTextColor.Sprint(name),
} }
@ -77,7 +77,7 @@ func getDisplayStringsForReflogCommit(c *models.Commit, attrs reflogCommitDispla
} }
return []string{ return []string{
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()), reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()),
theme.DefaultTextColor.Sprint(name), theme.DefaultTextColor.Sprint(name),
} }
} }

View file

@ -177,7 +177,7 @@ func SafeTruncate(str string, limit int) string {
const COMMIT_HASH_SHORT_SIZE = 8 const COMMIT_HASH_SHORT_SIZE = 8
func ShortSha(hash string) string { func ShortHash(hash string) string {
if len(hash) < COMMIT_HASH_SHORT_SIZE { if len(hash) < COMMIT_HASH_SHORT_SIZE {
return hash return hash
} }