mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-02 23:27:32 +02:00
rename sha to hash 10, last remaining sha (hopefully)
This commit is contained in:
parent
170c4ecb8c
commit
19bef17042
@ -365,7 +365,7 @@ func TestGetCommitMessageFromHistory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Default case to retrieve a commit in history",
|
"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) {
|
func(output string, err error) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "use generics to DRY up context code", output)
|
assert.Equal(t, "use generics to DRY up context code", output)
|
||||||
|
@ -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 {
|
func (self *RebaseCommands) MoveCommitsDown(commits []*models.Commit, startIdx int, endIdx int) error {
|
||||||
baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+2)
|
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 commit.Hash
|
||||||
})
|
})
|
||||||
|
|
||||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||||
baseHashOrRoot: baseHashOrRoot,
|
baseHashOrRoot: baseHashOrRoot,
|
||||||
instruction: daemon.NewMoveTodosDownInstruction(shas),
|
instruction: daemon.NewMoveTodosDownInstruction(hashes),
|
||||||
overrideEditor: true,
|
overrideEditor: true,
|
||||||
}).Run()
|
}).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 {
|
func (self *RebaseCommands) MoveCommitsUp(commits []*models.Commit, startIdx int, endIdx int) error {
|
||||||
baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+1)
|
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 commit.Hash
|
||||||
})
|
})
|
||||||
|
|
||||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||||
baseHashOrRoot: baseHashOrRoot,
|
baseHashOrRoot: baseHashOrRoot,
|
||||||
instruction: daemon.NewMoveTodosUpInstruction(shas),
|
instruction: daemon.NewMoveTodosUpInstruction(hashes),
|
||||||
overrideEditor: true,
|
overrideEditor: true,
|
||||||
}).Run()
|
}).Run()
|
||||||
}
|
}
|
||||||
@ -364,13 +364,13 @@ func (self *RebaseCommands) MoveTodosUp(commits []*models.Commit) error {
|
|||||||
|
|
||||||
// SquashAllAboveFixupCommits squashes all fixup! commits above the given one
|
// SquashAllAboveFixupCommits squashes all fixup! commits above the given one
|
||||||
func (self *RebaseCommands) SquashAllAboveFixupCommits(commit *models.Commit) error {
|
func (self *RebaseCommands) SquashAllAboveFixupCommits(commit *models.Commit) error {
|
||||||
shaOrRoot := commit.Hash + "^"
|
hashOrRoot := commit.Hash + "^"
|
||||||
if commit.IsFirstCommit() {
|
if commit.IsFirstCommit() {
|
||||||
shaOrRoot = "--root"
|
hashOrRoot = "--root"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArgs := NewGitCmd("rebase").
|
cmdArgs := NewGitCmd("rebase").
|
||||||
Arg("--interactive", "--rebase-merges", "--autostash", "--autosquash", shaOrRoot).
|
Arg("--interactive", "--rebase-merges", "--autostash", "--autosquash", hashOrRoot).
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
|
||||||
return self.runSkipEditorCommand(self.cmd.New(cmdArgs))
|
return self.runSkipEditorCommand(self.cmd.New(cmdArgs))
|
||||||
@ -503,7 +503,7 @@ func (self *RebaseCommands) DiscardOldFileChanges(commits []*models.Commit, comm
|
|||||||
return self.ContinueRebase()
|
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 {
|
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.ShortHash(commit.Hash), commit.Name)
|
return fmt.Sprintf("%s %s", utils.ShortHash(commit.Hash), commit.Name)
|
||||||
|
@ -154,7 +154,7 @@ func TestStashRename(t *testing.T) {
|
|||||||
index int
|
index int
|
||||||
message string
|
message string
|
||||||
expectedHashCmd []string
|
expectedHashCmd []string
|
||||||
shaResult string
|
hashResult string
|
||||||
expectedDropCmd []string
|
expectedDropCmd []string
|
||||||
expectedStoreCmd []string
|
expectedStoreCmd []string
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ func TestStashRename(t *testing.T) {
|
|||||||
index: 3,
|
index: 3,
|
||||||
message: "New message",
|
message: "New message",
|
||||||
expectedHashCmd: []string{"rev-parse", "refs/stash@{3}"},
|
expectedHashCmd: []string{"rev-parse", "refs/stash@{3}"},
|
||||||
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
|
hashResult: "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"},
|
||||||
},
|
},
|
||||||
@ -174,7 +174,7 @@ func TestStashRename(t *testing.T) {
|
|||||||
index: 4,
|
index: 4,
|
||||||
message: "",
|
message: "",
|
||||||
expectedHashCmd: []string{"rev-parse", "refs/stash@{4}"},
|
expectedHashCmd: []string{"rev-parse", "refs/stash@{4}"},
|
||||||
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
|
hashResult: "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.expectedHashCmd, s.shaResult, nil).
|
ExpectGitArgs(s.expectedHashCmd, s.hashResult, 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})
|
||||||
|
@ -79,8 +79,8 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
// use the selected commit in that case.
|
// use the selected commit in that case.
|
||||||
|
|
||||||
bisecting := info.GetCurrentHash() != ""
|
bisecting := info.GetCurrentHash() != ""
|
||||||
shaToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash)
|
hashToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash)
|
||||||
shortHashToMark := utils.ShortHash(shaToMark)
|
shortHashToMark := utils.ShortHash(hashToMark)
|
||||||
|
|
||||||
// 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
|
||||||
@ -95,7 +95,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, 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(hashToMark, info.NewTerm()); err != nil {
|
||||||
return self.c.Error(err)
|
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()),
|
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(hashToMark, info.OldTerm()); err != nil {
|
||||||
return self.c.Error(err)
|
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),
|
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(hashToMark); err != nil {
|
||||||
return self.c.Error(err)
|
return self.c.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ func reflogHashColor(cherryPicked, diffed bool) style.TextStyle {
|
|||||||
return theme.DiffTerminalColor
|
return theme.DiffTerminalColor
|
||||||
}
|
}
|
||||||
|
|
||||||
shaColor := style.FgBlue
|
hashColor := style.FgBlue
|
||||||
if cherryPicked {
|
if cherryPicked {
|
||||||
shaColor = theme.CherryPickedCommitTextStyle
|
hashColor = theme.CherryPickedCommitTextStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
return shaColor
|
return hashColor
|
||||||
}
|
}
|
||||||
|
|
||||||
type reflogCommitDisplayAttributes struct {
|
type reflogCommitDisplayAttributes struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user