1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Associate branches with worktrees even when mid-rebase

This commit is contained in:
Jesse Duffield
2023-07-17 13:40:26 +10:00
parent 6f2f9f6677
commit ec839e9e96
8 changed files with 104 additions and 37 deletions

View File

@ -5,6 +5,7 @@ import (
"strings"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
@ -23,10 +24,11 @@ func GetBranchListDisplayStrings(
diffName string,
tr *i18n.TranslationSet,
userConfig *config.UserConfig,
worktrees []*models.Worktree,
) [][]string {
return slices.Map(branches, func(branch *models.Branch) []string {
diffed := branch.Name == diffName
return getBranchDisplayStrings(branch, fullDescription, diffed, tr, userConfig)
return getBranchDisplayStrings(branch, fullDescription, diffed, tr, userConfig, worktrees)
})
}
@ -37,6 +39,7 @@ func getBranchDisplayStrings(
diffed bool,
tr *i18n.TranslationSet,
userConfig *config.UserConfig,
worktrees []*models.Worktree,
) []string {
displayName := b.Name
if b.DisplayName != "" {
@ -50,7 +53,7 @@ func getBranchDisplayStrings(
coloredName := nameTextStyle.Sprint(displayName)
branchStatus := utils.WithPadding(ColoredBranchStatus(b, tr), 2, utils.AlignLeft)
if b.CheckedOutByOtherWorktree {
if git_commands.CheckedOutByOtherWorktree(b, worktrees) {
worktreeIcon := lo.Ternary(icons.IsIconEnabled(), icons.LINKED_WORKTREE_ICON, fmt.Sprintf("(%s)", tr.LcWorktree))
coloredName = fmt.Sprintf("%s %s", coloredName, style.FgDefault.Sprint(worktreeIcon))
}