summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-17 13:56:50 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:22 +1000
commit3cd2d6fa5ce0a6e81e887d7f24988e76b2c987ba (patch)
tree044158b04607c95a10819d2f2370fd701ce0e580 /pkg/gui
parentec839e9e9671e365b75cdc270d6f3602981fb9bb (diff)
Hide worktree functionality on old git versions
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/controllers.go22
-rw-r--r--pkg/gui/controllers/helpers/refresh_helper.go5
-rw-r--r--pkg/gui/gui.go39
3 files changed, 40 insertions, 26 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go
index 9d76349c7..9536fbd8f 100644
--- a/pkg/gui/controllers.go
+++ b/pkg/gui/controllers.go
@@ -242,16 +242,18 @@ func (gui *Gui) resetHelpersAndControllers() {
controllers.AttachControllers(context, controllers.NewBasicCommitsController(common, context))
}
- for _, context := range []controllers.CanViewWorktreeOptions{
- gui.State.Contexts.LocalCommits,
- gui.State.Contexts.ReflogCommits,
- gui.State.Contexts.SubCommits,
- gui.State.Contexts.Stash,
- gui.State.Contexts.Branches,
- gui.State.Contexts.RemoteBranches,
- gui.State.Contexts.Tags,
- } {
- controllers.AttachControllers(context, controllers.NewWorktreeOptionsController(common, context))
+ if gui.c.Git().Version.SupportsWorktrees() {
+ for _, context := range []controllers.CanViewWorktreeOptions{
+ gui.State.Contexts.LocalCommits,
+ gui.State.Contexts.ReflogCommits,
+ gui.State.Contexts.SubCommits,
+ gui.State.Contexts.Stash,
+ gui.State.Contexts.Branches,
+ gui.State.Contexts.RemoteBranches,
+ gui.State.Contexts.Tags,
+ } {
+ controllers.AttachControllers(context, controllers.NewWorktreeOptionsController(common, context))
+ }
}
controllers.AttachControllers(gui.State.Contexts.ReflogCommits,
diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go
index 310958ffd..3edd801f9 100644
--- a/pkg/gui/controllers/helpers/refresh_helper.go
+++ b/pkg/gui/controllers/helpers/refresh_helper.go
@@ -598,6 +598,11 @@ func (self *RefreshHelper) refreshRemotes() error {
}
func (self *RefreshHelper) refreshWorktrees() error {
+ if !self.c.Git().Version.SupportsWorktrees() {
+ self.c.Model().Worktrees = []*models.Worktree{}
+ return nil
+ }
+
worktrees, err := self.c.Git().Loaders.Worktrees.GetWorktrees()
if err != nil {
return self.c.Error(err)
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index e0bff880a..1b58c7a9a 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -566,25 +566,32 @@ func (gui *Gui) initGocui(headless bool, test integrationTypes.IntegrationTest)
}
func (gui *Gui) viewTabMap() map[string][]context.TabView {
- return map[string][]context.TabView{
- "branches": {
- {
- Tab: gui.c.Tr.LocalBranchesTitle,
- ViewName: "localBranches",
- },
- {
- Tab: gui.c.Tr.RemotesTitle,
- ViewName: "remotes",
- },
- {
- Tab: gui.c.Tr.TagsTitle,
- ViewName: "tags",
- },
- {
+ branchesTabs := []context.TabView{
+ {
+ Tab: gui.c.Tr.LocalBranchesTitle,
+ ViewName: "localBranches",
+ },
+ {
+ Tab: gui.c.Tr.RemotesTitle,
+ ViewName: "remotes",
+ },
+ {
+ Tab: gui.c.Tr.TagsTitle,
+ ViewName: "tags",
+ },
+ }
+
+ if gui.c.Git().Version.SupportsWorktrees() {
+ branchesTabs = append(branchesTabs,
+ context.TabView{
Tab: gui.c.Tr.WorktreesTitle,
ViewName: "worktrees",
},
- },
+ )
+ }
+
+ return map[string][]context.TabView{
+ "branches": branchesTabs,
"commits": {
{
Tab: gui.c.Tr.CommitsTitle,