1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-23 22:24:51 +02:00

Better logic for knowing which repo we're in

This commit is contained in:
Jesse Duffield
2023-07-17 14:38:08 +10:00
parent a06a5cadee
commit b73efb2c22
8 changed files with 54 additions and 24 deletions

View File

@@ -5,12 +5,12 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/utils"
)
func FormatStatus(currentBranch *models.Branch, linkedWorktreeName string, workingTreeState enums.RebaseMode, tr *i18n.TranslationSet) string {
func FormatStatus(repoName string, currentBranch *models.Branch, linkedWorktreeName string, workingTreeState enums.RebaseMode, tr *i18n.TranslationSet) string {
status := ""
if currentBranch.IsRealBranch() {
@@ -22,10 +22,13 @@ func FormatStatus(currentBranch *models.Branch, linkedWorktreeName string, worki
}
name := GetBranchTextStyle(currentBranch.Name).Sprint(currentBranch.Name)
repoName := utils.GetCurrentRepoName()
// If the user is in a linked worktree (i.e. not the main worktree) we'll display that
if linkedWorktreeName != "" {
repoName = fmt.Sprintf("%s(%s)", repoName, style.FgCyan.Sprint(linkedWorktreeName))
icon := ""
if icons.IsIconEnabled() {
icon = icons.LINKED_WORKTREE_ICON + " "
}
repoName = fmt.Sprintf("%s(%s%s)", repoName, icon, style.FgCyan.Sprint(linkedWorktreeName))
}
status += fmt.Sprintf("%s → %s ", repoName, name)