mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
Update status to differentiate the main vs linked worktrees
This commit is contained in:
parent
afc4aedd4f
commit
60872c91e6
@ -45,7 +45,17 @@ func (gui *Gui) resetHelpersAndControllers() {
|
||||
patchBuildingHelper := helpers.NewPatchBuildingHelper(helperCommon)
|
||||
stagingHelper := helpers.NewStagingHelper(helperCommon)
|
||||
mergeConflictsHelper := helpers.NewMergeConflictsHelper(helperCommon)
|
||||
refreshHelper := helpers.NewRefreshHelper(helperCommon, refsHelper, rebaseHelper, patchBuildingHelper, stagingHelper, mergeConflictsHelper, gui.fileWatcher)
|
||||
worktreeHelper := helpers.NewWorktreeHelper(helperCommon)
|
||||
refreshHelper := helpers.NewRefreshHelper(
|
||||
helperCommon,
|
||||
refsHelper,
|
||||
rebaseHelper,
|
||||
patchBuildingHelper,
|
||||
stagingHelper,
|
||||
mergeConflictsHelper,
|
||||
worktreeHelper,
|
||||
gui.fileWatcher,
|
||||
)
|
||||
diffHelper := helpers.NewDiffHelper(helperCommon)
|
||||
cherryPickHelper := helpers.NewCherryPickHelper(
|
||||
helperCommon,
|
||||
@ -99,7 +109,8 @@ func (gui *Gui) resetHelpersAndControllers() {
|
||||
modeHelper,
|
||||
appStatusHelper,
|
||||
),
|
||||
Search: helpers.NewSearchHelper(helperCommon),
|
||||
Search: helpers.NewSearchHelper(helperCommon),
|
||||
Worktree: worktreeHelper,
|
||||
}
|
||||
|
||||
gui.CustomCommandsClient = custom_commands.NewClient(
|
||||
|
@ -47,6 +47,7 @@ type Helpers struct {
|
||||
AppStatus *AppStatusHelper
|
||||
WindowArrangement *WindowArrangementHelper
|
||||
Search *SearchHelper
|
||||
Worktree *WorktreeHelper
|
||||
}
|
||||
|
||||
func NewStubHelpers() *Helpers {
|
||||
@ -80,5 +81,6 @@ func NewStubHelpers() *Helpers {
|
||||
AppStatus: &AppStatusHelper{},
|
||||
WindowArrangement: &WindowArrangementHelper{},
|
||||
Search: &SearchHelper{},
|
||||
Worktree: &WorktreeHelper{},
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ type RefreshHelper struct {
|
||||
patchBuildingHelper *PatchBuildingHelper
|
||||
stagingHelper *StagingHelper
|
||||
mergeConflictsHelper *MergeConflictsHelper
|
||||
worktreeHelper *WorktreeHelper
|
||||
fileWatcher types.IFileWatcher
|
||||
}
|
||||
|
||||
@ -38,6 +39,7 @@ func NewRefreshHelper(
|
||||
patchBuildingHelper *PatchBuildingHelper,
|
||||
stagingHelper *StagingHelper,
|
||||
mergeConflictsHelper *MergeConflictsHelper,
|
||||
worktreeHelper *WorktreeHelper,
|
||||
fileWatcher types.IFileWatcher,
|
||||
) *RefreshHelper {
|
||||
return &RefreshHelper{
|
||||
@ -47,6 +49,7 @@ func NewRefreshHelper(
|
||||
patchBuildingHelper: patchBuildingHelper,
|
||||
stagingHelper: stagingHelper,
|
||||
mergeConflictsHelper: mergeConflictsHelper,
|
||||
worktreeHelper: worktreeHelper,
|
||||
fileWatcher: fileWatcher,
|
||||
}
|
||||
}
|
||||
@ -635,8 +638,16 @@ func (self *RefreshHelper) refreshStatus() {
|
||||
}
|
||||
|
||||
name := presentation.GetBranchTextStyle(currentBranch.Name).Sprint(currentBranch.Name)
|
||||
repoName := utils.GetCurrentRepoName()
|
||||
status += fmt.Sprintf("%s → %s ", repoName, name)
|
||||
|
||||
var repoName string
|
||||
worktreeName := self.worktreeHelper.GetCurrentWorktreeName()
|
||||
if len(worktreeName) > 0 {
|
||||
worktreeName = fmt.Sprintf("[%s]", worktreeName)
|
||||
repoName = self.worktreeHelper.GetMainWorktreeName()
|
||||
} else {
|
||||
repoName = utils.GetCurrentRepoName()
|
||||
}
|
||||
status += fmt.Sprintf("%s%s → %s ", repoName, worktreeName, name)
|
||||
|
||||
self.c.SetViewContent(self.c.Views().Status, status)
|
||||
}
|
||||
|
43
pkg/gui/controllers/helpers/worktree_helper.go
Normal file
43
pkg/gui/controllers/helpers/worktree_helper.go
Normal file
@ -0,0 +1,43 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type IWorktreeHelper interface {
|
||||
GetMainWorktreeName() string
|
||||
GetCurrentWorktreeName() string
|
||||
}
|
||||
|
||||
type WorktreeHelper struct {
|
||||
c *HelperCommon
|
||||
}
|
||||
|
||||
func NewWorktreeHelper(c *HelperCommon) *WorktreeHelper {
|
||||
return &WorktreeHelper{
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *WorktreeHelper) GetMainWorktreeName() string {
|
||||
for _, worktree := range self.c.Model().Worktrees {
|
||||
if worktree.Main {
|
||||
return filepath.Base(worktree.Path)
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *WorktreeHelper) GetCurrentWorktreeName() string {
|
||||
for _, worktree := range self.c.Model().Worktrees {
|
||||
if worktree.Current {
|
||||
if worktree.Main {
|
||||
return ""
|
||||
}
|
||||
return worktree.Name
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
Loading…
Reference in New Issue
Block a user