rename sha to hash 10, last remaining sha (hopefully)

This commit is contained in:
pikomonde 2024-03-21 02:23:10 +07:00 committed by Stefan Haller
parent 170c4ecb8c
commit 19bef17042
5 changed files with 21 additions and 21 deletions

View file

@ -365,7 +365,7 @@ func TestGetCommitMessageFromHistory(t *testing.T) {
},
{
"Default case to retrieve a commit in history",
oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "-1", "--skip=2", "--pretty=%H"}, "sha3 \n", nil).ExpectGitArgs([]string{"-c", "log.showsignature=false", "log", "--format=%B", "--max-count=1", "sha3"}, `use generics to DRY up context code`, nil),
oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "-1", "--skip=2", "--pretty=%H"}, "hash3 \n", nil).ExpectGitArgs([]string{"-c", "log.showsignature=false", "log", "--format=%B", "--max-count=1", "hash3"}, `use generics to DRY up context code`, nil),
func(output string, err error) {
assert.NoError(t, err)
assert.Equal(t, "use generics to DRY up context code", output)

View file

@ -108,13 +108,13 @@ func (self *RebaseCommands) GenericAmend(commits []*models.Commit, index int, f
func (self *RebaseCommands) MoveCommitsDown(commits []*models.Commit, startIdx int, endIdx int) error {
baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+2)
shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
hashes := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
return commit.Hash
})
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseHashOrRoot: baseHashOrRoot,
instruction: daemon.NewMoveTodosDownInstruction(shas),
instruction: daemon.NewMoveTodosDownInstruction(hashes),
overrideEditor: true,
}).Run()
}
@ -122,13 +122,13 @@ func (self *RebaseCommands) MoveCommitsDown(commits []*models.Commit, startIdx i
func (self *RebaseCommands) MoveCommitsUp(commits []*models.Commit, startIdx int, endIdx int) error {
baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+1)
shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
hashes := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
return commit.Hash
})
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseHashOrRoot: baseHashOrRoot,
instruction: daemon.NewMoveTodosUpInstruction(shas),
instruction: daemon.NewMoveTodosUpInstruction(hashes),
overrideEditor: true,
}).Run()
}
@ -364,13 +364,13 @@ func (self *RebaseCommands) MoveTodosUp(commits []*models.Commit) error {
// SquashAllAboveFixupCommits squashes all fixup! commits above the given one
func (self *RebaseCommands) SquashAllAboveFixupCommits(commit *models.Commit) error {
shaOrRoot := commit.Hash + "^"
hashOrRoot := commit.Hash + "^"
if commit.IsFirstCommit() {
shaOrRoot = "--root"
hashOrRoot = "--root"
}
cmdArgs := NewGitCmd("rebase").
Arg("--interactive", "--rebase-merges", "--autostash", "--autosquash", shaOrRoot).
Arg("--interactive", "--rebase-merges", "--autostash", "--autosquash", hashOrRoot).
ToArgv()
return self.runSkipEditorCommand(self.cmd.New(cmdArgs))
@ -503,7 +503,7 @@ func (self *RebaseCommands) DiscardOldFileChanges(commits []*models.Commit, comm
return self.ContinueRebase()
}
// CherryPickCommits begins an interactive rebase with the given shas being cherry picked onto HEAD
// CherryPickCommits begins an interactive rebase with the given hashes 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.ShortHash(commit.Hash), commit.Name)

View file

@ -154,7 +154,7 @@ func TestStashRename(t *testing.T) {
index int
message string
expectedHashCmd []string
shaResult string
hashResult string
expectedDropCmd []string
expectedStoreCmd []string
}
@ -165,7 +165,7 @@ func TestStashRename(t *testing.T) {
index: 3,
message: "New message",
expectedHashCmd: []string{"rev-parse", "refs/stash@{3}"},
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
hashResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
expectedDropCmd: []string{"stash", "drop", "stash@{3}"},
expectedStoreCmd: []string{"stash", "store", "-m", "New message", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"},
},
@ -174,7 +174,7 @@ func TestStashRename(t *testing.T) {
index: 4,
message: "",
expectedHashCmd: []string{"rev-parse", "refs/stash@{4}"},
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
hashResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
expectedDropCmd: []string{"stash", "drop", "stash@{4}"},
expectedStoreCmd: []string{"stash", "store", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"},
},
@ -184,7 +184,7 @@ func TestStashRename(t *testing.T) {
s := s
t.Run(s.testName, func(t *testing.T) {
runner := oscommands.NewFakeRunner(t).
ExpectGitArgs(s.expectedHashCmd, s.shaResult, nil).
ExpectGitArgs(s.expectedHashCmd, s.hashResult, nil).
ExpectGitArgs(s.expectedDropCmd, "", nil).
ExpectGitArgs(s.expectedStoreCmd, "", nil)
instance := buildStashCommands(commonDeps{runner: runner})

View file

@ -79,8 +79,8 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
// use the selected commit in that case.
bisecting := info.GetCurrentHash() != ""
shaToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash)
shortHashToMark := utils.ShortHash(shaToMark)
hashToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash)
shortHashToMark := utils.ShortHash(hashToMark)
// 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
@ -95,7 +95,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, info.NewTerm()),
OnPress: func() error {
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(hashToMark, info.NewTerm()); err != nil {
return self.c.Error(err)
}
@ -108,7 +108,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, info.OldTerm()),
OnPress: func() error {
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(hashToMark, info.OldTerm()); err != nil {
return self.c.Error(err)
}
@ -121,7 +121,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
Label: fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortHashToMark),
OnPress: func() error {
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(hashToMark); err != nil {
return self.c.Error(err)
}

View file

@ -40,12 +40,12 @@ func reflogHashColor(cherryPicked, diffed bool) style.TextStyle {
return theme.DiffTerminalColor
}
shaColor := style.FgBlue
hashColor := style.FgBlue
if cherryPicked {
shaColor = theme.CherryPickedCommitTextStyle
hashColor = theme.CherryPickedCommitTextStyle
}
return shaColor
return hashColor
}
type reflogCommitDisplayAttributes struct {