summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-17 14:38:08 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:22 +1000
commitb73efb2c22bfe587b58210da8f130469430066ed (patch)
tree17e1800de789e7f40d0661ad5ffce6068e915ba0 /pkg/gui
parenta06a5cadee1763d3360af698e7c2e1bbe915b3e0 (diff)
Better logic for knowing which repo we're in
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/controllers/helpers/refresh_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/working_tree_helper.go4
-rw-r--r--pkg/gui/controllers/status_controller.go5
-rw-r--r--pkg/gui/presentation/status.go11
4 files changed, 15 insertions, 9 deletions
diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go
index f1e24eecc..ffbd85a59 100644
--- a/pkg/gui/controllers/helpers/refresh_helper.go
+++ b/pkg/gui/controllers/helpers/refresh_helper.go
@@ -637,7 +637,9 @@ func (self *RefreshHelper) refreshStatus() {
linkedWorktreeName = self.worktreeHelper.GetLinkedWorktreeName()
}
- status := presentation.FormatStatus(currentBranch, linkedWorktreeName, workingTreeState, self.c.Tr)
+ repoName := git_commands.GetCurrentRepoName()
+
+ status := presentation.FormatStatus(repoName, currentBranch, linkedWorktreeName, workingTreeState, self.c.Tr)
self.c.SetViewContent(self.c.Views().Status, status)
}
diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go
index 22d1089c9..a0a0447d7 100644
--- a/pkg/gui/controllers/helpers/working_tree_helper.go
+++ b/pkg/gui/controllers/helpers/working_tree_helper.go
@@ -4,11 +4,11 @@ import (
"fmt"
"regexp"
+ "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/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
- "github.com/jesseduffield/lazygit/pkg/utils"
)
type IWorkingTreeHelper interface {
@@ -203,7 +203,7 @@ func (self *WorkingTreeHelper) prepareFilesForCommit() error {
}
func (self *WorkingTreeHelper) commitPrefixConfigForRepo() *config.CommitPrefixConfig {
- cfg, ok := self.c.UserConfig.Git.CommitPrefixes[utils.GetCurrentRepoName()]
+ cfg, ok := self.c.UserConfig.Git.CommitPrefixes[git_commands.GetCurrentRepoName()]
if !ok {
return nil
}
diff --git a/pkg/gui/controllers/status_controller.go b/pkg/gui/controllers/status_controller.go
index 8661b99b3..d8e906f3b 100644
--- a/pkg/gui/controllers/status_controller.go
+++ b/pkg/gui/controllers/status_controller.go
@@ -6,12 +6,12 @@ import (
"strings"
"github.com/jesseduffield/generics/slices"
+ "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
- "github.com/jesseduffield/lazygit/pkg/utils"
)
type StatusController struct {
@@ -108,7 +108,8 @@ func (self *StatusController) onClick() error {
cx, _ := self.c.Views().Status.Cursor()
upstreamStatus := presentation.BranchStatus(currentBranch, self.c.Tr)
- repoName := utils.GetCurrentRepoName()
+ // TODO: support worktrees here
+ repoName := git_commands.GetCurrentRepoName()
workingTreeState := self.c.Git().Status.WorkingTreeState()
switch workingTreeState {
case enums.REBASE_MODE_REBASING, enums.REBASE_MODE_MERGING:
diff --git a/pkg/gui/presentation/status.go b/pkg/gui/presentation/status.go
index 650303d44..f70210c27 100644
--- a/pkg/gui/presentation/status.go
+++ b/pkg/gui/presentation/status.go
@@ -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)