mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Remove worktree version guards
Our min required git version is 2.20 so there's no need to add guards for worktrees because they were added in 2.5
This commit is contained in:
		| @@ -69,7 +69,3 @@ func (v *GitVersion) IsOlderThan(major, minor, patch int) bool { | ||||
| func (v *GitVersion) IsOlderThanVersion(version *GitVersion) bool { | ||||
| 	return v.IsOlderThan(version.Major, version.Minor, version.Patch) | ||||
| } | ||||
|  | ||||
| func (v *GitVersion) SupportsWorktrees() bool { | ||||
| 	return !v.IsOlderThan(2, 5, 0) | ||||
| } | ||||
|   | ||||
| @@ -242,18 +242,16 @@ func (gui *Gui) resetHelpersAndControllers() { | ||||
| 		controllers.AttachControllers(context, controllers.NewBasicCommitsController(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)) | ||||
| 		} | ||||
| 	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, | ||||
|   | ||||
| @@ -598,11 +598,6 @@ 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 { | ||||
| 		self.c.Log.Error(err) | ||||
| @@ -634,10 +629,7 @@ func (self *RefreshHelper) refreshStatus() { | ||||
| 	} | ||||
|  | ||||
| 	workingTreeState := self.c.Git().Status.WorkingTreeState() | ||||
| 	var linkedWorktreeName string | ||||
| 	if self.c.Git().Version.SupportsWorktrees() { | ||||
| 		linkedWorktreeName = self.worktreeHelper.GetLinkedWorktreeName() | ||||
| 	} | ||||
| 	linkedWorktreeName := self.worktreeHelper.GetLinkedWorktreeName() | ||||
|  | ||||
| 	repoName := git_commands.GetCurrentRepoName() | ||||
|  | ||||
|   | ||||
| @@ -596,6 +596,10 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView { | ||||
| 				Tab:      gui.c.Tr.FilesTitle, | ||||
| 				ViewName: "files", | ||||
| 			}, | ||||
| 			context.TabView{ | ||||
| 				Tab:      gui.c.Tr.WorktreesTitle, | ||||
| 				ViewName: "worktrees", | ||||
| 			}, | ||||
| 			{ | ||||
| 				Tab:      gui.c.Tr.SubmodulesTitle, | ||||
| 				ViewName: "submodules", | ||||
| @@ -603,17 +607,6 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView { | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	if gui.c.Git().Version.SupportsWorktrees() { | ||||
| 		// insert between files and submodules tabs | ||||
| 		result["files"] = append(result["files"][0:1], | ||||
| 			context.TabView{ | ||||
| 				Tab:      gui.c.Tr.WorktreesTitle, | ||||
| 				ViewName: "worktrees", | ||||
| 			}, | ||||
| 			result["files"][1], | ||||
| 		) | ||||
| 	} | ||||
|  | ||||
| 	return result | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user