2023-07-16 17:15:19 +10:00
|
|
|
package presentation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
2023-07-17 14:38:08 +10:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
2023-07-16 17:15:19 +10:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
2023-10-08 18:09:29 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
2023-07-16 17:15:19 +10:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
|
|
|
)
|
|
|
|
|
2023-10-08 18:09:29 +02:00
|
|
|
func FormatStatus(repoName string, currentBranch *models.Branch, itemOperation types.ItemOperation, linkedWorktreeName string, workingTreeState enums.RebaseMode, tr *i18n.TranslationSet) string {
|
2023-07-16 17:15:19 +10:00
|
|
|
status := ""
|
|
|
|
|
|
|
|
if currentBranch.IsRealBranch() {
|
2023-10-08 18:09:29 +02:00
|
|
|
status += ColoredBranchStatus(currentBranch, itemOperation, tr) + " "
|
2023-07-16 17:15:19 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if workingTreeState != enums.REBASE_MODE_NONE {
|
|
|
|
status += style.FgYellow.Sprintf("(%s) ", FormatWorkingTreeStateLower(tr, workingTreeState))
|
|
|
|
}
|
|
|
|
|
|
|
|
name := GetBranchTextStyle(currentBranch.Name).Sprint(currentBranch.Name)
|
2023-07-17 14:10:07 +10:00
|
|
|
// If the user is in a linked worktree (i.e. not the main worktree) we'll display that
|
|
|
|
if linkedWorktreeName != "" {
|
2023-07-17 14:38:08 +10:00
|
|
|
icon := ""
|
|
|
|
if icons.IsIconEnabled() {
|
|
|
|
icon = icons.LINKED_WORKTREE_ICON + " "
|
|
|
|
}
|
|
|
|
repoName = fmt.Sprintf("%s(%s%s)", repoName, icon, style.FgCyan.Sprint(linkedWorktreeName))
|
2023-07-16 17:15:19 +10:00
|
|
|
}
|
|
|
|
status += fmt.Sprintf("%s → %s ", repoName, name)
|
|
|
|
|
|
|
|
return status
|
|
|
|
}
|