1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-27 12:32:37 +02:00

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
// if lazygit was built from source we'll show the version as the
// 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

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
func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error {
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(
self.Tr.Log.CherryPickCommits,

View File

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

View File

@ -22,7 +22,7 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
viewModel := NewFilteredListViewModel(
func() []*models.Commit { return c.Model().FilteredReflogCommits },
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() != ""
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
// 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 {
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 {
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
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,
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 {
self.c.LogAction(self.c.Tr.Actions.StartBisect)
if err := self.c.Git().Bisect.Start(); err != nil {
@ -182,7 +182,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
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 {
self.c.LogAction(self.c.Tr.Actions.StartBisect)
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)
} else {
// detached HEAD state, displaying short SHA
branchDisplay = utils.ShortSha(content)
branchDisplay = utils.ShortHash(content)
}
return branchDisplay, nil
}

View File

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

View File

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

View File

@ -373,7 +373,7 @@ func displayCommit(
} else if icons.IsIconEnabled() {
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)
if fullDescription {
cols = append(cols, style.FgBlue.Sprint(

View File

@ -64,7 +64,7 @@ func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, attrs ref
}
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)),
theme.DefaultTextColor.Sprint(name),
}
@ -77,7 +77,7 @@ func getDisplayStringsForReflogCommit(c *models.Commit, attrs reflogCommitDispla
}
return []string{
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortSha()),
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()),
theme.DefaultTextColor.Sprint(name),
}
}

View File

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