mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Don't put "<--- YOU ARE HERE" in the commit model's name
Instead, derive it from context at display time (if we're rebasing, it's the first non-todo commit). This fixes the problem that unfolding the current commit's files in the local commits panel would show junk in the frame's title. Along the way we make sure to only display the "<--- YOU ARE HERE" string in the local commits panel; previously it would show for the top commit of a branch or tag if mid-rebase.
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
package presentation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/generics/set"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||
@ -32,6 +34,7 @@ type bisectBounds struct {
|
||||
}
|
||||
|
||||
func GetCommitListDisplayStrings(
|
||||
common *common.Common,
|
||||
commits []*models.Commit,
|
||||
fullDescription bool,
|
||||
cherryPickedCommitShaSet *set.Set[string],
|
||||
@ -43,6 +46,7 @@ func GetCommitListDisplayStrings(
|
||||
length int,
|
||||
showGraph bool,
|
||||
bisectInfo *git_commands.BisectInfo,
|
||||
showYouAreHereLabel bool,
|
||||
) [][]string {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
@ -95,7 +99,9 @@ func GetCommitListDisplayStrings(
|
||||
for i, commit := range filteredCommits {
|
||||
unfilteredIdx := i + startIdx
|
||||
bisectStatus = getBisectStatus(unfilteredIdx, commit.Sha, bisectInfo, bisectBounds)
|
||||
isYouAreHereCommit := showYouAreHereLabel && unfilteredIdx == rebaseOffset
|
||||
lines = append(lines, displayCommit(
|
||||
common,
|
||||
commit,
|
||||
cherryPickedCommitShaSet,
|
||||
diffName,
|
||||
@ -105,6 +111,7 @@ func GetCommitListDisplayStrings(
|
||||
fullDescription,
|
||||
bisectStatus,
|
||||
bisectInfo,
|
||||
isYouAreHereCommit,
|
||||
))
|
||||
}
|
||||
return lines
|
||||
@ -240,6 +247,7 @@ func getBisectStatusText(bisectStatus BisectStatus, bisectInfo *git_commands.Bis
|
||||
}
|
||||
|
||||
func displayCommit(
|
||||
common *common.Common,
|
||||
commit *models.Commit,
|
||||
cherryPickedCommitShaSet *set.Set[string],
|
||||
diffName string,
|
||||
@ -249,6 +257,7 @@ func displayCommit(
|
||||
fullDescription bool,
|
||||
bisectStatus BisectStatus,
|
||||
bisectInfo *git_commands.BisectInfo,
|
||||
isYouAreHereCommit bool,
|
||||
) []string {
|
||||
shaColor := getShaColor(commit, diffName, cherryPickedCommitShaSet, bisectStatus, bisectInfo)
|
||||
bisectString := getBisectStatusText(bisectStatus, bisectInfo)
|
||||
@ -274,6 +283,11 @@ func displayCommit(
|
||||
name = emoji.Sprint(name)
|
||||
}
|
||||
|
||||
if isYouAreHereCommit {
|
||||
youAreHere := style.FgYellow.Sprintf("<-- %s ---", common.Tr.YouAreHere)
|
||||
name = fmt.Sprintf("%s %s", youAreHere, name)
|
||||
}
|
||||
|
||||
authorFunc := authors.ShortAuthor
|
||||
if fullDescription {
|
||||
authorFunc = authors.LongAuthor
|
||||
|
Reference in New Issue
Block a user