rename sha to hash 9, case: Sha

This commit is contained in:
pikomonde 2024-03-21 02:14:17 +07:00 committed by Stefan Haller
parent de1c495704
commit 170c4ecb8c
12 changed files with 90 additions and 90 deletions

View file

@ -230,10 +230,10 @@ type MoveFixupCommitDownInstruction struct {
FixupHash string FixupHash string
} }
func NewMoveFixupCommitDownInstruction(originalSha string, fixupSha string) Instruction { func NewMoveFixupCommitDownInstruction(originalHash string, fixupHash string) Instruction {
return &MoveFixupCommitDownInstruction{ return &MoveFixupCommitDownInstruction{
OriginalHash: originalSha, OriginalHash: originalHash,
FixupHash: fixupSha, FixupHash: fixupHash,
} }
} }

View file

@ -94,8 +94,8 @@ func (self *BisectCommands) GetInfoForGitDir(gitDir string) *BisectInfo {
self.Log.Infof("error getting git bisect info: %s", err.Error()) self.Log.Infof("error getting git bisect info: %s", err.Error())
return info return info
} }
currentSha := strings.TrimSpace(string(currentContent)) currentHash := strings.TrimSpace(string(currentContent))
info.current = currentSha info.current = currentHash
return info return info
} }
@ -143,8 +143,8 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
return false, nil, nil return false, nil, nil
} }
newSha := info.GetNewHash() newHash := info.GetNewHash()
if newSha == "" { if newHash == "" {
return false, nil, nil return false, nil, nil
} }
@ -153,7 +153,7 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
done := false done := false
candidates := []string{} candidates := []string{}
cmdArgs := NewGitCmd("rev-list").Arg(newSha).ToArgv() cmdArgs := NewGitCmd("rev-list").Arg(newHash).ToArgv()
err := self.cmd.New(cmdArgs).RunAndProcessLines(func(line string) (bool, error) { err := self.cmd.New(cmdArgs).RunAndProcessLines(func(line string) (bool, error) {
hash := strings.TrimSpace(line) hash := strings.TrimSpace(line)

View file

@ -163,7 +163,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
self.os.LogCommand(logTodoChanges(changes), false) self.os.LogCommand(logTodoChanges(changes), false)
err := self.rebase.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ err := self.rebase.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: commits[baseIndex].Hash, baseHashOrRoot: commits[baseIndex].Hash,
overrideEditor: true, overrideEditor: true,
instruction: daemon.NewChangeTodoActionsInstruction(changes), instruction: daemon.NewChangeTodoActionsInstruction(changes),
}).Run() }).Run()

View file

@ -62,8 +62,8 @@ func (self *RebaseCommands) RewordCommitInEditor(commits []*models.Commit, index
self.os.LogCommand(logTodoChanges(changes), false) self.os.LogCommand(logTodoChanges(changes), false)
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: getBaseShaOrRoot(commits, index+1), baseHashOrRoot: getBaseHashOrRoot(commits, index+1),
instruction: daemon.NewChangeTodoActionsInstruction(changes), instruction: daemon.NewChangeTodoActionsInstruction(changes),
}), nil }), nil
} }
@ -106,28 +106,28 @@ func (self *RebaseCommands) GenericAmend(commits []*models.Commit, index int, f
} }
func (self *RebaseCommands) MoveCommitsDown(commits []*models.Commit, startIdx int, endIdx int) error { func (self *RebaseCommands) MoveCommitsDown(commits []*models.Commit, startIdx int, endIdx int) error {
baseShaOrRoot := getBaseShaOrRoot(commits, endIdx+2) baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+2)
shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string { shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
return commit.Hash return commit.Hash
}) })
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: baseShaOrRoot, baseHashOrRoot: baseHashOrRoot,
instruction: daemon.NewMoveTodosDownInstruction(shas), instruction: daemon.NewMoveTodosDownInstruction(shas),
overrideEditor: true, overrideEditor: true,
}).Run() }).Run()
} }
func (self *RebaseCommands) MoveCommitsUp(commits []*models.Commit, startIdx int, endIdx int) error { func (self *RebaseCommands) MoveCommitsUp(commits []*models.Commit, startIdx int, endIdx int) error {
baseShaOrRoot := getBaseShaOrRoot(commits, endIdx+1) baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+1)
shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string { shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
return commit.Hash return commit.Hash
}) })
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: baseShaOrRoot, baseHashOrRoot: baseHashOrRoot,
instruction: daemon.NewMoveTodosUpInstruction(shas), instruction: daemon.NewMoveTodosUpInstruction(shas),
overrideEditor: true, overrideEditor: true,
}).Run() }).Run()
@ -139,7 +139,7 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx
baseIndex++ baseIndex++
} }
baseShaOrRoot := getBaseShaOrRoot(commits, baseIndex) baseHashOrRoot := getBaseHashOrRoot(commits, baseIndex)
changes := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) daemon.ChangeTodoAction { changes := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) daemon.ChangeTodoAction {
return daemon.ChangeTodoAction{ return daemon.ChangeTodoAction{
@ -151,7 +151,7 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx
self.os.LogCommand(logTodoChanges(changes), false) self.os.LogCommand(logTodoChanges(changes), false)
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: baseShaOrRoot, baseHashOrRoot: baseHashOrRoot,
overrideEditor: true, overrideEditor: true,
instruction: daemon.NewChangeTodoActionsInstruction(changes), instruction: daemon.NewChangeTodoActionsInstruction(changes),
}).Run() }).Run()
@ -166,8 +166,8 @@ func (self *RebaseCommands) EditRebase(branchRef string) error {
) )
self.os.LogCommand(msg, false) self.os.LogCommand(msg, false)
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: branchRef, baseHashOrRoot: branchRef,
instruction: daemon.NewInsertBreakInstruction(), instruction: daemon.NewInsertBreakInstruction(),
}).Run() }).Run()
} }
@ -181,9 +181,9 @@ func (self *RebaseCommands) EditRebaseFromBaseCommit(targetBranchName string, ba
) )
self.os.LogCommand(msg, false) self.os.LogCommand(msg, false)
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: baseCommit, baseHashOrRoot: baseCommit,
onto: targetBranchName, onto: targetBranchName,
instruction: daemon.NewInsertBreakInstruction(), instruction: daemon.NewInsertBreakInstruction(),
}).Run() }).Run()
} }
@ -195,7 +195,7 @@ func logTodoChanges(changes []daemon.ChangeTodoAction) string {
} }
type PrepareInteractiveRebaseCommandOpts struct { type PrepareInteractiveRebaseCommandOpts struct {
baseShaOrRoot string baseHashOrRoot string
onto string onto string
instruction daemon.Instruction instruction daemon.Instruction
overrideEditor bool overrideEditor bool
@ -216,7 +216,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract
Arg("--no-autosquash"). Arg("--no-autosquash").
ArgIf(self.version.IsAtLeast(2, 22, 0), "--rebase-merges"). ArgIf(self.version.IsAtLeast(2, 22, 0), "--rebase-merges").
ArgIf(opts.onto != "", "--onto", opts.onto). ArgIf(opts.onto != "", "--onto", opts.onto).
Arg(opts.baseShaOrRoot). Arg(opts.baseHashOrRoot).
ToArgv() ToArgv()
debug := "FALSE" debug := "FALSE"
@ -290,15 +290,15 @@ func (self *RebaseCommands) AmendTo(commits []*models.Commit, commitIndex int) e
// Get the hash of the commit we just created // Get the hash of the commit we just created
cmdArgs := NewGitCmd("rev-parse").Arg("--verify", "HEAD").ToArgv() cmdArgs := NewGitCmd("rev-parse").Arg("--verify", "HEAD").ToArgv()
fixupSha, err := self.cmd.New(cmdArgs).RunWithOutput() fixupHash, err := self.cmd.New(cmdArgs).RunWithOutput()
if err != nil { if err != nil {
return err return err
} }
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: getBaseShaOrRoot(commits, commitIndex+1), baseHashOrRoot: getBaseHashOrRoot(commits, commitIndex+1),
overrideEditor: true, overrideEditor: true,
instruction: daemon.NewMoveFixupCommitDownInstruction(commit.Hash, fixupSha), instruction: daemon.NewMoveFixupCommitDownInstruction(commit.Hash, fixupHash),
}).Run() }).Run()
} }
@ -399,7 +399,7 @@ func (self *RebaseCommands) BeginInteractiveRebaseForCommit(
self.os.LogCommand(logTodoChanges(changes), false) self.os.LogCommand(logTodoChanges(changes), false)
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: getBaseShaOrRoot(commits, commitIndex+1), baseHashOrRoot: getBaseHashOrRoot(commits, commitIndex+1),
overrideEditor: true, overrideEditor: true,
keepCommitsThatBecomeEmpty: keepCommitsThatBecomeEmpty, keepCommitsThatBecomeEmpty: keepCommitsThatBecomeEmpty,
instruction: daemon.NewChangeTodoActionsInstruction(changes), instruction: daemon.NewChangeTodoActionsInstruction(changes),
@ -408,13 +408,13 @@ func (self *RebaseCommands) BeginInteractiveRebaseForCommit(
// RebaseBranch interactive rebases onto a branch // RebaseBranch interactive rebases onto a branch
func (self *RebaseCommands) RebaseBranch(branchName string) error { func (self *RebaseCommands) RebaseBranch(branchName string) error {
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{baseShaOrRoot: branchName}).Run() return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{baseHashOrRoot: branchName}).Run()
} }
func (self *RebaseCommands) RebaseBranchFromBaseCommit(targetBranchName string, baseCommit string) error { func (self *RebaseCommands) RebaseBranchFromBaseCommit(targetBranchName string, baseCommit string) error {
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: baseCommit, baseHashOrRoot: baseCommit,
onto: targetBranchName, onto: targetBranchName,
}).Run() }).Run()
} }
@ -517,8 +517,8 @@ func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error {
self.os.LogCommand(msg, false) self.os.LogCommand(msg, false)
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseShaOrRoot: "HEAD", baseHashOrRoot: "HEAD",
instruction: daemon.NewCherryPickCommitsInstruction(commits), instruction: daemon.NewCherryPickCommitsInstruction(commits),
}).Run() }).Run()
} }
@ -538,7 +538,7 @@ func (self *RebaseCommands) CherryPickCommitsDuringRebase(commits []*models.Comm
// we can't start an interactive rebase from the first commit without passing the // we can't start an interactive rebase from the first commit without passing the
// '--root' arg // '--root' arg
func getBaseShaOrRoot(commits []*models.Commit, index int) string { func getBaseHashOrRoot(commits []*models.Commit, index int) string {
// We assume that the commits slice contains the initial commit of the repo. // We assume that the commits slice contains the initial commit of the repo.
// Technically this assumption could prove false, but it's unlikely you'll // Technically this assumption could prove false, but it's unlikely you'll
// be starting a rebase from 300 commits ago (which is the original commit limit // be starting a rebase from 300 commits ago (which is the original commit limit

View file

@ -86,7 +86,7 @@ func TestStashStore(t *testing.T) {
} }
} }
func TestStashSha(t *testing.T) { func TestStashHash(t *testing.T) {
runner := oscommands.NewFakeRunner(t). runner := oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"rev-parse", "refs/stash@{5}"}, "14d94495194651adfd5f070590df566c11d28243\n", nil) ExpectGitArgs([]string{"rev-parse", "refs/stash@{5}"}, "14d94495194651adfd5f070590df566c11d28243\n", nil)
instance := buildStashCommands(commonDeps{runner: runner}) instance := buildStashCommands(commonDeps{runner: runner})
@ -153,7 +153,7 @@ func TestStashRename(t *testing.T) {
testName string testName string
index int index int
message string message string
expectedShaCmd []string expectedHashCmd []string
shaResult string shaResult string
expectedDropCmd []string expectedDropCmd []string
expectedStoreCmd []string expectedStoreCmd []string
@ -164,7 +164,7 @@ func TestStashRename(t *testing.T) {
testName: "Default case", testName: "Default case",
index: 3, index: 3,
message: "New message", message: "New message",
expectedShaCmd: []string{"rev-parse", "refs/stash@{3}"}, expectedHashCmd: []string{"rev-parse", "refs/stash@{3}"},
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n", shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
expectedDropCmd: []string{"stash", "drop", "stash@{3}"}, expectedDropCmd: []string{"stash", "drop", "stash@{3}"},
expectedStoreCmd: []string{"stash", "store", "-m", "New message", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"}, expectedStoreCmd: []string{"stash", "store", "-m", "New message", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"},
@ -173,7 +173,7 @@ func TestStashRename(t *testing.T) {
testName: "Empty message", testName: "Empty message",
index: 4, index: 4,
message: "", message: "",
expectedShaCmd: []string{"rev-parse", "refs/stash@{4}"}, expectedHashCmd: []string{"rev-parse", "refs/stash@{4}"},
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n", shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
expectedDropCmd: []string{"stash", "drop", "stash@{4}"}, expectedDropCmd: []string{"stash", "drop", "stash@{4}"},
expectedStoreCmd: []string{"stash", "store", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"}, expectedStoreCmd: []string{"stash", "store", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"},
@ -184,7 +184,7 @@ func TestStashRename(t *testing.T) {
s := s s := s
t.Run(s.testName, func(t *testing.T) { t.Run(s.testName, func(t *testing.T) {
runner := oscommands.NewFakeRunner(t). runner := oscommands.NewFakeRunner(t).
ExpectGitArgs(s.expectedShaCmd, s.shaResult, nil). ExpectGitArgs(s.expectedHashCmd, s.shaResult, nil).
ExpectGitArgs(s.expectedDropCmd, "", nil). ExpectGitArgs(s.expectedDropCmd, "", nil).
ExpectGitArgs(s.expectedStoreCmd, "", nil) ExpectGitArgs(s.expectedStoreCmd, "", nil)
instance := buildStashCommands(commonDeps{runner: runner}) instance := buildStashCommands(commonDeps{runner: runner})

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.ShortHash(shaToMark) shortHashToMark := 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
@ -92,7 +92,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
menuItems := []*types.MenuItem{ menuItems := []*types.MenuItem{
{ {
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortShaToMark, info.NewTerm()), Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, info.NewTerm()),
OnPress: func() error { OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectMark) self.c.LogAction(self.c.Tr.Actions.BisectMark)
if err := self.c.Git().Bisect.Mark(shaToMark, info.NewTerm()); err != nil { if err := self.c.Git().Bisect.Mark(shaToMark, info.NewTerm()); err != nil {
@ -105,7 +105,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 'b', Key: 'b',
}, },
{ {
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortShaToMark, info.OldTerm()), Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, info.OldTerm()),
OnPress: func() error { OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.BisectMark) self.c.LogAction(self.c.Tr.Actions.BisectMark)
if err := self.c.Git().Bisect.Mark(shaToMark, info.OldTerm()); err != nil { if err := self.c.Git().Bisect.Mark(shaToMark, info.OldTerm()); err != nil {
@ -118,7 +118,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Key: 'g', Key: 'g',
}, },
{ {
Label: fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortShaToMark), Label: fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortHashToMark),
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(shaToMark); err != nil { if err := self.c.Git().Bisect.Skip(shaToMark); err != nil {
@ -224,13 +224,13 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
}) })
} }
func (self *BisectController) showBisectCompleteMessage(candidateShas []string) error { func (self *BisectController) showBisectCompleteMessage(candidateHashes []string) error {
prompt := self.c.Tr.Bisect.CompletePrompt prompt := self.c.Tr.Bisect.CompletePrompt
if len(candidateShas) > 1 { if len(candidateHashes) > 1 {
prompt = self.c.Tr.Bisect.CompletePromptIndeterminate prompt = self.c.Tr.Bisect.CompletePromptIndeterminate
} }
formattedCommits, err := self.c.Git().Commit.GetCommitsOneline(candidateShas) formattedCommits, err := self.c.Git().Commit.GetCommitsOneline(candidateHashes)
if err != nil { if err != nil {
return self.c.Error(err) return self.c.Error(err)
} }
@ -250,7 +250,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateShas []string)
} }
func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) error { func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) error {
done, candidateShas, err := self.c.Git().Bisect.IsDone() done, candidateHashes, err := self.c.Git().Bisect.IsDone()
if err != nil { if err != nil {
return self.c.Error(err) return self.c.Error(err)
} }
@ -260,7 +260,7 @@ func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool)
} }
if done { if done {
return self.showBisectCompleteMessage(candidateShas) return self.showBisectCompleteMessage(candidateHashes)
} }
return nil return nil

View file

@ -508,8 +508,8 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
self.c.LogAction(self.c.Tr.Actions.EditCommit) self.c.LogAction(self.c.Tr.Actions.EditCommit)
selectedIdx, rangeStartIdx, rangeSelectMode := self.context().GetSelectionRangeAndMode() selectedIdx, rangeStartIdx, rangeSelectMode := self.context().GetSelectionRangeAndMode()
commits := self.c.Model().Commits commits := self.c.Model().Commits
selectedSha := commits[selectedIdx].Hash selectedHash := commits[selectedIdx].Hash
rangeStartSha := commits[rangeStartIdx].Hash rangeStartHash := commits[rangeStartIdx].Hash
err := self.c.Git().Rebase.EditRebase(commitsToEdit[len(commitsToEdit)-1].Hash) err := self.c.Git().Rebase.EditRebase(commitsToEdit[len(commitsToEdit)-1].Hash)
return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions( return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions(
err, err,
@ -532,10 +532,10 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
// new lines can be added for update-ref commands in the TODO file, due to // new lines can be added for update-ref commands in the TODO file, due to
// stacked branches. So the selected commits may be in different positions in the list. // stacked branches. So the selected commits may be in different positions in the list.
_, newSelectedIdx, ok1 := lo.FindIndexOf(self.c.Model().Commits, func(c *models.Commit) bool { _, newSelectedIdx, ok1 := lo.FindIndexOf(self.c.Model().Commits, func(c *models.Commit) bool {
return c.Hash == selectedSha return c.Hash == selectedHash
}) })
_, newRangeStartIdx, ok2 := lo.FindIndexOf(self.c.Model().Commits, func(c *models.Commit) bool { _, newRangeStartIdx, ok2 := lo.FindIndexOf(self.c.Model().Commits, func(c *models.Commit) bool {
return c.Hash == rangeStartSha return c.Hash == rangeStartHash
}) })
if ok1 && ok2 { if ok1 && ok2 {
self.context().SetSelectionRangeAndMode(newSelectedIdx, newRangeStartIdx, rangeSelectMode) self.context().SetSelectionRangeAndMode(newSelectedIdx, newRangeStartIdx, rangeSelectMode)
@ -799,15 +799,15 @@ func (self *LocalCommitsController) revert(commit *models.Commit) error {
func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.Commit) error { func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.Commit) error {
menuItems := make([]*types.MenuItem, len(commit.Parents)) menuItems := make([]*types.MenuItem, len(commit.Parents))
for i, parentSha := range commit.Parents { for i, parentHash := range commit.Parents {
i := i i := i
message, err := self.c.Git().Commit.GetCommitMessageFirstLine(parentSha) message, err := self.c.Git().Commit.GetCommitMessageFirstLine(parentHash)
if err != nil { if err != nil {
return self.c.Error(err) return self.c.Error(err)
} }
menuItems[i] = &types.MenuItem{ menuItems[i] = &types.MenuItem{
Label: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message), Label: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentHash, 8), message),
OnPress: func() error { OnPress: func() error {
parentNumber := i + 1 parentNumber := i + 1
self.c.LogAction(self.c.Tr.Actions.RevertCommit) self.c.LogAction(self.c.Tr.Actions.RevertCommit)

View file

@ -312,7 +312,7 @@ func displayCommit(
bisectInfo *git_commands.BisectInfo, bisectInfo *git_commands.BisectInfo,
isYouAreHereCommit bool, isYouAreHereCommit bool,
) []string { ) []string {
shaColor := getShaColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo) hashColor := getHashColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
bisectString := getBisectStatusText(bisectStatus, bisectInfo) bisectString := getBisectStatusText(bisectStatus, bisectInfo)
actionString := "" actionString := ""
@ -369,11 +369,11 @@ func displayCommit(
cols := make([]string, 0, 7) cols := make([]string, 0, 7)
if commit.Divergence != models.DivergenceNone { if commit.Divergence != models.DivergenceNone {
cols = append(cols, shaColor.Sprint(lo.Ternary(commit.Divergence == models.DivergenceLeft, "↑", "↓"))) cols = append(cols, hashColor.Sprint(lo.Ternary(commit.Divergence == models.DivergenceLeft, "↑", "↓")))
} else if icons.IsIconEnabled() { } else if icons.IsIconEnabled() {
cols = append(cols, shaColor.Sprint(icons.IconForCommit(commit))) cols = append(cols, hashColor.Sprint(icons.IconForCommit(commit)))
} }
cols = append(cols, shaColor.Sprint(commit.ShortHash())) cols = append(cols, hashColor.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(
@ -410,7 +410,7 @@ func getBisectStatusColor(status BisectStatus) style.TextStyle {
return style.FgWhite return style.FgWhite
} }
func getShaColor( func getHashColor(
commit *models.Commit, commit *models.Commit,
diffName string, diffName string,
cherryPickedCommitHashSet *set.Set[string], cherryPickedCommitHashSet *set.Set[string],
@ -422,30 +422,30 @@ func getShaColor(
} }
diffed := commit.Hash != "" && commit.Hash == diffName diffed := commit.Hash != "" && commit.Hash == diffName
shaColor := theme.DefaultTextColor hashColor := theme.DefaultTextColor
switch commit.Status { switch commit.Status {
case models.StatusUnpushed: case models.StatusUnpushed:
shaColor = style.FgRed hashColor = style.FgRed
case models.StatusPushed: case models.StatusPushed:
shaColor = style.FgYellow hashColor = style.FgYellow
case models.StatusMerged: case models.StatusMerged:
shaColor = style.FgGreen hashColor = style.FgGreen
case models.StatusRebasing: case models.StatusRebasing:
shaColor = style.FgBlue hashColor = style.FgBlue
case models.StatusReflog: case models.StatusReflog:
shaColor = style.FgBlue hashColor = style.FgBlue
default: default:
} }
if diffed { if diffed {
shaColor = theme.DiffTerminalColor hashColor = theme.DiffTerminalColor
} else if cherryPickedCommitHashSet.Includes(commit.Hash) { } else if cherryPickedCommitHashSet.Includes(commit.Hash) {
shaColor = theme.CherryPickedCommitTextStyle hashColor = theme.CherryPickedCommitTextStyle
} else if commit.Divergence == models.DivergenceRight && commit.Status != models.StatusMerged { } else if commit.Divergence == models.DivergenceRight && commit.Status != models.StatusMerged {
shaColor = style.FgBlue hashColor = style.FgBlue
} }
return shaColor return hashColor
} }
func actionColorMap(action todo.TodoCommand) style.TextStyle { func actionColorMap(action todo.TodoCommand) style.TextStyle {

View file

@ -35,7 +35,7 @@ func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription
}) })
} }
func reflogShaColor(cherryPicked, diffed bool) style.TextStyle { func reflogHashColor(cherryPicked, diffed bool) style.TextStyle {
if diffed { if diffed {
return theme.DiffTerminalColor return theme.DiffTerminalColor
} }
@ -64,7 +64,7 @@ func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, attrs ref
} }
return []string{ return []string{
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()), reflogHashColor(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.ShortHash()), reflogHashColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()),
theme.DefaultTextColor.Sprint(name), theme.DefaultTextColor.Sprint(name),
} }
} }

View file

@ -1875,11 +1875,11 @@ func EnglishTranslationSet() TranslationSet {
}, },
Log: Log{ Log: Log{
EditRebase: "Beginning interactive rebase at '{{.ref}}'", EditRebase: "Beginning interactive rebase at '{{.ref}}'",
MoveCommitUp: "Moving TODO down: '{{.shortSha}}'", MoveCommitUp: "Moving TODO down: '{{.shortHash}}'",
MoveCommitDown: "Moving TODO down: '{{.shortSha}}'", MoveCommitDown: "Moving TODO down: '{{.shortHash}}'",
CherryPickCommits: "Cherry-picking commits:\n'{{.commitLines}}'", CherryPickCommits: "Cherry-picking commits:\n'{{.commitLines}}'",
HandleUndo: "Undoing last conflict resolution", HandleUndo: "Undoing last conflict resolution",
HandleMidRebaseCommand: "Updating rebase action of commit {{.shortSha}} to '{{.action}}'", HandleMidRebaseCommand: "Updating rebase action of commit {{.shortHash}} to '{{.action}}'",
RemoveFile: "Deleting path '{{.path}}'", RemoveFile: "Deleting path '{{.path}}'",
CopyToClipboard: "Copying '{{.str}}' to clipboard", CopyToClipboard: "Copying '{{.str}}' to clipboard",
Remove: "Removing '{{.filename}}'", Remove: "Removing '{{.filename}}'",

View file

@ -887,11 +887,11 @@ func polishTranslationSet() TranslationSet {
}, },
Log: Log{ Log: Log{
EditRebase: "Rozpoczynanie interaktywnego rebazowania od '{{.ref}}'", EditRebase: "Rozpoczynanie interaktywnego rebazowania od '{{.ref}}'",
MoveCommitUp: "Przenoszenie TODO w dół: '{{.shortSha}}'", MoveCommitUp: "Przenoszenie TODO w dół: '{{.shortHash}}'",
MoveCommitDown: "Przenoszenie TODO w dół: '{{.shortSha}}'", MoveCommitDown: "Przenoszenie TODO w dół: '{{.shortHash}}'",
CherryPickCommits: "Cherry-picking commitów:\n'{{.commitLines}}'", CherryPickCommits: "Cherry-picking commitów:\n'{{.commitLines}}'",
HandleUndo: "Cofanie ostatniego rozwiązania konfliktu", HandleUndo: "Cofanie ostatniego rozwiązania konfliktu",
HandleMidRebaseCommand: "Aktualizacja akcji rebazowania commita {{.shortSha}} na '{{.action}}'", HandleMidRebaseCommand: "Aktualizacja akcji rebazowania commita {{.shortHash}} na '{{.action}}'",
RemoveFile: "Usuwanie ścieżki '{{.path}}'", RemoveFile: "Usuwanie ścieżki '{{.path}}'",
CopyToClipboard: "Kopiowanie '{{.str}}' do schowka", CopyToClipboard: "Kopiowanie '{{.str}}' do schowka",
Remove: "Usuwanie '{{.filename}}'", Remove: "Usuwanie '{{.filename}}'",

View file

@ -219,13 +219,13 @@ func moveTodosUp(todos []todo.Todo, todosToMove []Todo) ([]todo.Todo, error) {
return todos, nil return todos, nil
} }
func MoveFixupCommitDown(fileName string, originalSha string, fixupSha string, commentChar byte) error { func MoveFixupCommitDown(fileName string, originalHash string, fixupHash string, commentChar byte) error {
todos, err := ReadRebaseTodoFile(fileName, commentChar) todos, err := ReadRebaseTodoFile(fileName, commentChar)
if err != nil { if err != nil {
return err return err
} }
newTodos, err := moveFixupCommitDown(todos, originalSha, fixupSha) newTodos, err := moveFixupCommitDown(todos, originalHash, fixupHash)
if err != nil { if err != nil {
return err return err
} }
@ -233,23 +233,23 @@ func MoveFixupCommitDown(fileName string, originalSha string, fixupSha string, c
return WriteRebaseTodoFile(fileName, newTodos, commentChar) return WriteRebaseTodoFile(fileName, newTodos, commentChar)
} }
func moveFixupCommitDown(todos []todo.Todo, originalSha string, fixupSha string) ([]todo.Todo, error) { func moveFixupCommitDown(todos []todo.Todo, originalHash string, fixupHash string) ([]todo.Todo, error) {
isOriginal := func(t todo.Todo) bool { isOriginal := func(t todo.Todo) bool {
return t.Command == todo.Pick && equalHash(t.Commit, originalSha) return t.Command == todo.Pick && equalHash(t.Commit, originalHash)
} }
isFixup := func(t todo.Todo) bool { isFixup := func(t todo.Todo) bool {
return t.Command == todo.Pick && equalHash(t.Commit, fixupSha) return t.Command == todo.Pick && equalHash(t.Commit, fixupHash)
} }
originalShaCount := lo.CountBy(todos, isOriginal) originalHashCount := lo.CountBy(todos, isOriginal)
if originalShaCount != 1 { if originalHashCount != 1 {
return nil, fmt.Errorf("Expected exactly one original hash, found %d", originalShaCount) return nil, fmt.Errorf("Expected exactly one original hash, found %d", originalHashCount)
} }
fixupShaCount := lo.CountBy(todos, isFixup) fixupHashCount := lo.CountBy(todos, isFixup)
if fixupShaCount != 1 { if fixupHashCount != 1 {
return nil, fmt.Errorf("Expected exactly one fixup hash, found %d", fixupShaCount) return nil, fmt.Errorf("Expected exactly one fixup hash, found %d", fixupHashCount)
} }
_, fixupIndex, _ := lo.FindIndexOf(todos, isFixup) _, fixupIndex, _ := lo.FindIndexOf(todos, isFixup)