mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
rename sha to hash 9, case: Sha
This commit is contained in:
parent
de1c495704
commit
170c4ecb8c
12 changed files with 90 additions and 90 deletions
|
@ -230,10 +230,10 @@ type MoveFixupCommitDownInstruction struct {
|
|||
FixupHash string
|
||||
}
|
||||
|
||||
func NewMoveFixupCommitDownInstruction(originalSha string, fixupSha string) Instruction {
|
||||
func NewMoveFixupCommitDownInstruction(originalHash string, fixupHash string) Instruction {
|
||||
return &MoveFixupCommitDownInstruction{
|
||||
OriginalHash: originalSha,
|
||||
FixupHash: fixupSha,
|
||||
OriginalHash: originalHash,
|
||||
FixupHash: fixupHash,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ func (self *BisectCommands) GetInfoForGitDir(gitDir string) *BisectInfo {
|
|||
self.Log.Infof("error getting git bisect info: %s", err.Error())
|
||||
return info
|
||||
}
|
||||
currentSha := strings.TrimSpace(string(currentContent))
|
||||
info.current = currentSha
|
||||
currentHash := strings.TrimSpace(string(currentContent))
|
||||
info.current = currentHash
|
||||
|
||||
return info
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
|
|||
return false, nil, nil
|
||||
}
|
||||
|
||||
newSha := info.GetNewHash()
|
||||
if newSha == "" {
|
||||
newHash := info.GetNewHash()
|
||||
if newHash == "" {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
|
|||
done := false
|
||||
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) {
|
||||
hash := strings.TrimSpace(line)
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
|
|||
self.os.LogCommand(logTodoChanges(changes), false)
|
||||
|
||||
err := self.rebase.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: commits[baseIndex].Hash,
|
||||
baseHashOrRoot: commits[baseIndex].Hash,
|
||||
overrideEditor: true,
|
||||
instruction: daemon.NewChangeTodoActionsInstruction(changes),
|
||||
}).Run()
|
||||
|
|
|
@ -62,8 +62,8 @@ func (self *RebaseCommands) RewordCommitInEditor(commits []*models.Commit, index
|
|||
self.os.LogCommand(logTodoChanges(changes), false)
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: getBaseShaOrRoot(commits, index+1),
|
||||
instruction: daemon.NewChangeTodoActionsInstruction(changes),
|
||||
baseHashOrRoot: getBaseHashOrRoot(commits, index+1),
|
||||
instruction: daemon.NewChangeTodoActionsInstruction(changes),
|
||||
}), 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 {
|
||||
baseShaOrRoot := getBaseShaOrRoot(commits, endIdx+2)
|
||||
baseHashOrRoot := getBaseHashOrRoot(commits, endIdx+2)
|
||||
|
||||
shas := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) string {
|
||||
return commit.Hash
|
||||
})
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: baseShaOrRoot,
|
||||
baseHashOrRoot: baseHashOrRoot,
|
||||
instruction: daemon.NewMoveTodosDownInstruction(shas),
|
||||
overrideEditor: true,
|
||||
}).Run()
|
||||
}
|
||||
|
||||
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 {
|
||||
return commit.Hash
|
||||
})
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: baseShaOrRoot,
|
||||
baseHashOrRoot: baseHashOrRoot,
|
||||
instruction: daemon.NewMoveTodosUpInstruction(shas),
|
||||
overrideEditor: true,
|
||||
}).Run()
|
||||
|
@ -139,7 +139,7 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx
|
|||
baseIndex++
|
||||
}
|
||||
|
||||
baseShaOrRoot := getBaseShaOrRoot(commits, baseIndex)
|
||||
baseHashOrRoot := getBaseHashOrRoot(commits, baseIndex)
|
||||
|
||||
changes := lo.Map(commits[startIdx:endIdx+1], func(commit *models.Commit, _ int) daemon.ChangeTodoAction {
|
||||
return daemon.ChangeTodoAction{
|
||||
|
@ -151,7 +151,7 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx
|
|||
self.os.LogCommand(logTodoChanges(changes), false)
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: baseShaOrRoot,
|
||||
baseHashOrRoot: baseHashOrRoot,
|
||||
overrideEditor: true,
|
||||
instruction: daemon.NewChangeTodoActionsInstruction(changes),
|
||||
}).Run()
|
||||
|
@ -166,8 +166,8 @@ func (self *RebaseCommands) EditRebase(branchRef string) error {
|
|||
)
|
||||
self.os.LogCommand(msg, false)
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: branchRef,
|
||||
instruction: daemon.NewInsertBreakInstruction(),
|
||||
baseHashOrRoot: branchRef,
|
||||
instruction: daemon.NewInsertBreakInstruction(),
|
||||
}).Run()
|
||||
}
|
||||
|
||||
|
@ -181,9 +181,9 @@ func (self *RebaseCommands) EditRebaseFromBaseCommit(targetBranchName string, ba
|
|||
)
|
||||
self.os.LogCommand(msg, false)
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: baseCommit,
|
||||
onto: targetBranchName,
|
||||
instruction: daemon.NewInsertBreakInstruction(),
|
||||
baseHashOrRoot: baseCommit,
|
||||
onto: targetBranchName,
|
||||
instruction: daemon.NewInsertBreakInstruction(),
|
||||
}).Run()
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ func logTodoChanges(changes []daemon.ChangeTodoAction) string {
|
|||
}
|
||||
|
||||
type PrepareInteractiveRebaseCommandOpts struct {
|
||||
baseShaOrRoot string
|
||||
baseHashOrRoot string
|
||||
onto string
|
||||
instruction daemon.Instruction
|
||||
overrideEditor bool
|
||||
|
@ -216,7 +216,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract
|
|||
Arg("--no-autosquash").
|
||||
ArgIf(self.version.IsAtLeast(2, 22, 0), "--rebase-merges").
|
||||
ArgIf(opts.onto != "", "--onto", opts.onto).
|
||||
Arg(opts.baseShaOrRoot).
|
||||
Arg(opts.baseHashOrRoot).
|
||||
ToArgv()
|
||||
|
||||
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
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: getBaseShaOrRoot(commits, commitIndex+1),
|
||||
baseHashOrRoot: getBaseHashOrRoot(commits, commitIndex+1),
|
||||
overrideEditor: true,
|
||||
instruction: daemon.NewMoveFixupCommitDownInstruction(commit.Hash, fixupSha),
|
||||
instruction: daemon.NewMoveFixupCommitDownInstruction(commit.Hash, fixupHash),
|
||||
}).Run()
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ func (self *RebaseCommands) BeginInteractiveRebaseForCommit(
|
|||
self.os.LogCommand(logTodoChanges(changes), false)
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: getBaseShaOrRoot(commits, commitIndex+1),
|
||||
baseHashOrRoot: getBaseHashOrRoot(commits, commitIndex+1),
|
||||
overrideEditor: true,
|
||||
keepCommitsThatBecomeEmpty: keepCommitsThatBecomeEmpty,
|
||||
instruction: daemon.NewChangeTodoActionsInstruction(changes),
|
||||
|
@ -408,13 +408,13 @@ func (self *RebaseCommands) BeginInteractiveRebaseForCommit(
|
|||
|
||||
// RebaseBranch interactive rebases onto a branch
|
||||
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 {
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: baseCommit,
|
||||
onto: targetBranchName,
|
||||
baseHashOrRoot: baseCommit,
|
||||
onto: targetBranchName,
|
||||
}).Run()
|
||||
}
|
||||
|
||||
|
@ -517,8 +517,8 @@ func (self *RebaseCommands) CherryPickCommits(commits []*models.Commit) error {
|
|||
self.os.LogCommand(msg, false)
|
||||
|
||||
return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
|
||||
baseShaOrRoot: "HEAD",
|
||||
instruction: daemon.NewCherryPickCommitsInstruction(commits),
|
||||
baseHashOrRoot: "HEAD",
|
||||
instruction: daemon.NewCherryPickCommitsInstruction(commits),
|
||||
}).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
|
||||
// '--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.
|
||||
// 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
|
||||
|
|
|
@ -86,7 +86,7 @@ func TestStashStore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStashSha(t *testing.T) {
|
||||
func TestStashHash(t *testing.T) {
|
||||
runner := oscommands.NewFakeRunner(t).
|
||||
ExpectGitArgs([]string{"rev-parse", "refs/stash@{5}"}, "14d94495194651adfd5f070590df566c11d28243\n", nil)
|
||||
instance := buildStashCommands(commonDeps{runner: runner})
|
||||
|
@ -153,7 +153,7 @@ func TestStashRename(t *testing.T) {
|
|||
testName string
|
||||
index int
|
||||
message string
|
||||
expectedShaCmd []string
|
||||
expectedHashCmd []string
|
||||
shaResult string
|
||||
expectedDropCmd []string
|
||||
expectedStoreCmd []string
|
||||
|
@ -164,7 +164,7 @@ func TestStashRename(t *testing.T) {
|
|||
testName: "Default case",
|
||||
index: 3,
|
||||
message: "New message",
|
||||
expectedShaCmd: []string{"rev-parse", "refs/stash@{3}"},
|
||||
expectedHashCmd: []string{"rev-parse", "refs/stash@{3}"},
|
||||
shaResult: "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd\n",
|
||||
expectedDropCmd: []string{"stash", "drop", "stash@{3}"},
|
||||
expectedStoreCmd: []string{"stash", "store", "-m", "New message", "f0d0f20f2f61ffd6d6bfe0752deffa38845a3edd"},
|
||||
|
@ -173,7 +173,7 @@ func TestStashRename(t *testing.T) {
|
|||
testName: "Empty message",
|
||||
index: 4,
|
||||
message: "",
|
||||
expectedShaCmd: []string{"rev-parse", "refs/stash@{4}"},
|
||||
expectedHashCmd: []string{"rev-parse", "refs/stash@{4}"},
|
||||
shaResult: "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.expectedShaCmd, s.shaResult, nil).
|
||||
ExpectGitArgs(s.expectedHashCmd, s.shaResult, nil).
|
||||
ExpectGitArgs(s.expectedDropCmd, "", nil).
|
||||
ExpectGitArgs(s.expectedStoreCmd, "", nil)
|
||||
instance := buildStashCommands(commonDeps{runner: runner})
|
||||
|
|
|
@ -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.ShortHash(shaToMark)
|
||||
shortHashToMark := 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
|
||||
|
@ -92,7 +92,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||
|
||||
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 {
|
||||
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
||||
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',
|
||||
},
|
||||
{
|
||||
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 {
|
||||
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
||||
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',
|
||||
},
|
||||
{
|
||||
Label: fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortShaToMark),
|
||||
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 {
|
||||
|
@ -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
|
||||
if len(candidateShas) > 1 {
|
||||
if len(candidateHashes) > 1 {
|
||||
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 {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateShas []string)
|
|||
}
|
||||
|
||||
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 {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool)
|
|||
}
|
||||
|
||||
if done {
|
||||
return self.showBisectCompleteMessage(candidateShas)
|
||||
return self.showBisectCompleteMessage(candidateHashes)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -508,8 +508,8 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
|
|||
self.c.LogAction(self.c.Tr.Actions.EditCommit)
|
||||
selectedIdx, rangeStartIdx, rangeSelectMode := self.context().GetSelectionRangeAndMode()
|
||||
commits := self.c.Model().Commits
|
||||
selectedSha := commits[selectedIdx].Hash
|
||||
rangeStartSha := commits[rangeStartIdx].Hash
|
||||
selectedHash := commits[selectedIdx].Hash
|
||||
rangeStartHash := commits[rangeStartIdx].Hash
|
||||
err := self.c.Git().Rebase.EditRebase(commitsToEdit[len(commitsToEdit)-1].Hash)
|
||||
return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions(
|
||||
err,
|
||||
|
@ -532,10 +532,10 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
|
|||
// 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.
|
||||
_, 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 {
|
||||
return c.Hash == rangeStartSha
|
||||
return c.Hash == rangeStartHash
|
||||
})
|
||||
if ok1 && ok2 {
|
||||
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 {
|
||||
menuItems := make([]*types.MenuItem, len(commit.Parents))
|
||||
for i, parentSha := range commit.Parents {
|
||||
for i, parentHash := range commit.Parents {
|
||||
i := i
|
||||
message, err := self.c.Git().Commit.GetCommitMessageFirstLine(parentSha)
|
||||
message, err := self.c.Git().Commit.GetCommitMessageFirstLine(parentHash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
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 {
|
||||
parentNumber := i + 1
|
||||
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
|
||||
|
|
|
@ -312,7 +312,7 @@ func displayCommit(
|
|||
bisectInfo *git_commands.BisectInfo,
|
||||
isYouAreHereCommit bool,
|
||||
) []string {
|
||||
shaColor := getShaColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
|
||||
hashColor := getHashColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
|
||||
bisectString := getBisectStatusText(bisectStatus, bisectInfo)
|
||||
|
||||
actionString := ""
|
||||
|
@ -369,11 +369,11 @@ func displayCommit(
|
|||
|
||||
cols := make([]string, 0, 7)
|
||||
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() {
|
||||
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)
|
||||
if fullDescription {
|
||||
cols = append(cols, style.FgBlue.Sprint(
|
||||
|
@ -410,7 +410,7 @@ func getBisectStatusColor(status BisectStatus) style.TextStyle {
|
|||
return style.FgWhite
|
||||
}
|
||||
|
||||
func getShaColor(
|
||||
func getHashColor(
|
||||
commit *models.Commit,
|
||||
diffName string,
|
||||
cherryPickedCommitHashSet *set.Set[string],
|
||||
|
@ -422,30 +422,30 @@ func getShaColor(
|
|||
}
|
||||
|
||||
diffed := commit.Hash != "" && commit.Hash == diffName
|
||||
shaColor := theme.DefaultTextColor
|
||||
hashColor := theme.DefaultTextColor
|
||||
switch commit.Status {
|
||||
case models.StatusUnpushed:
|
||||
shaColor = style.FgRed
|
||||
hashColor = style.FgRed
|
||||
case models.StatusPushed:
|
||||
shaColor = style.FgYellow
|
||||
hashColor = style.FgYellow
|
||||
case models.StatusMerged:
|
||||
shaColor = style.FgGreen
|
||||
hashColor = style.FgGreen
|
||||
case models.StatusRebasing:
|
||||
shaColor = style.FgBlue
|
||||
hashColor = style.FgBlue
|
||||
case models.StatusReflog:
|
||||
shaColor = style.FgBlue
|
||||
hashColor = style.FgBlue
|
||||
default:
|
||||
}
|
||||
|
||||
if diffed {
|
||||
shaColor = theme.DiffTerminalColor
|
||||
hashColor = theme.DiffTerminalColor
|
||||
} else if cherryPickedCommitHashSet.Includes(commit.Hash) {
|
||||
shaColor = theme.CherryPickedCommitTextStyle
|
||||
hashColor = theme.CherryPickedCommitTextStyle
|
||||
} 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 {
|
||||
|
|
|
@ -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 {
|
||||
return theme.DiffTerminalColor
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, attrs ref
|
|||
}
|
||||
|
||||
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)),
|
||||
theme.DefaultTextColor.Sprint(name),
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func getDisplayStringsForReflogCommit(c *models.Commit, attrs reflogCommitDispla
|
|||
}
|
||||
|
||||
return []string{
|
||||
reflogShaColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()),
|
||||
reflogHashColor(attrs.cherryPicked, attrs.diffed).Sprint(c.ShortHash()),
|
||||
theme.DefaultTextColor.Sprint(name),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1875,11 +1875,11 @@ func EnglishTranslationSet() TranslationSet {
|
|||
},
|
||||
Log: Log{
|
||||
EditRebase: "Beginning interactive rebase at '{{.ref}}'",
|
||||
MoveCommitUp: "Moving TODO down: '{{.shortSha}}'",
|
||||
MoveCommitDown: "Moving TODO down: '{{.shortSha}}'",
|
||||
MoveCommitUp: "Moving TODO down: '{{.shortHash}}'",
|
||||
MoveCommitDown: "Moving TODO down: '{{.shortHash}}'",
|
||||
CherryPickCommits: "Cherry-picking commits:\n'{{.commitLines}}'",
|
||||
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}}'",
|
||||
CopyToClipboard: "Copying '{{.str}}' to clipboard",
|
||||
Remove: "Removing '{{.filename}}'",
|
||||
|
|
|
@ -887,11 +887,11 @@ func polishTranslationSet() TranslationSet {
|
|||
},
|
||||
Log: Log{
|
||||
EditRebase: "Rozpoczynanie interaktywnego rebazowania od '{{.ref}}'",
|
||||
MoveCommitUp: "Przenoszenie TODO w dół: '{{.shortSha}}'",
|
||||
MoveCommitDown: "Przenoszenie TODO w dół: '{{.shortSha}}'",
|
||||
MoveCommitUp: "Przenoszenie TODO w dół: '{{.shortHash}}'",
|
||||
MoveCommitDown: "Przenoszenie TODO w dół: '{{.shortHash}}'",
|
||||
CherryPickCommits: "Cherry-picking commitów:\n'{{.commitLines}}'",
|
||||
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}}'",
|
||||
CopyToClipboard: "Kopiowanie '{{.str}}' do schowka",
|
||||
Remove: "Usuwanie '{{.filename}}'",
|
||||
|
|
|
@ -219,13 +219,13 @@ func moveTodosUp(todos []todo.Todo, todosToMove []Todo) ([]todo.Todo, error) {
|
|||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newTodos, err := moveFixupCommitDown(todos, originalSha, fixupSha)
|
||||
newTodos, err := moveFixupCommitDown(todos, originalHash, fixupHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -233,23 +233,23 @@ func MoveFixupCommitDown(fileName string, originalSha string, fixupSha string, c
|
|||
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 {
|
||||
return t.Command == todo.Pick && equalHash(t.Commit, originalSha)
|
||||
return t.Command == todo.Pick && equalHash(t.Commit, originalHash)
|
||||
}
|
||||
|
||||
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)
|
||||
if originalShaCount != 1 {
|
||||
return nil, fmt.Errorf("Expected exactly one original hash, found %d", originalShaCount)
|
||||
originalHashCount := lo.CountBy(todos, isOriginal)
|
||||
if originalHashCount != 1 {
|
||||
return nil, fmt.Errorf("Expected exactly one original hash, found %d", originalHashCount)
|
||||
}
|
||||
|
||||
fixupShaCount := lo.CountBy(todos, isFixup)
|
||||
if fixupShaCount != 1 {
|
||||
return nil, fmt.Errorf("Expected exactly one fixup hash, found %d", fixupShaCount)
|
||||
fixupHashCount := lo.CountBy(todos, isFixup)
|
||||
if fixupHashCount != 1 {
|
||||
return nil, fmt.Errorf("Expected exactly one fixup hash, found %d", fixupHashCount)
|
||||
}
|
||||
|
||||
_, fixupIndex, _ := lo.FindIndexOf(todos, isFixup)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue