Skip to content

Commit 0bb6332

Browse files
author
Cameron Way
committed
Remove use of app state from showTags support
1 parent 399d887 commit 0bb6332

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

pkg/config/app_config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,8 @@ git:
698698
# displays the whole git graph by default in the commits view (equivalent to passing the --all argument to git log)
699699
showWholeGraph: false
700700
701-
# Configure this with Log menu -> 'Show commit tags' (<c-l> in the commits window by default).
701+
# This determines whether tags are displayed in the commits view
702+
# One of 'always' | 'never' | 'when-maximised'
702703
showTags: always
703704
704705
# When copying commit hashes to the clipboard, truncate them to this

pkg/config/user_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ type LogConfig struct {
337337
ShowGraph string `yaml:"showGraph" jsonschema:"deprecated,enum=always,enum=never,enum=when-maximised"`
338338
// displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)
339339
ShowWholeGraph bool `yaml:"showWholeGraph"`
340-
// Configure this with `Log menu -> Show tags` (<c-l> in the commits window by default).
340+
// This determines whether tags are displayed in the commits view
341341
ShowTags string `yaml:"showTags" jsonschema:"enum=always,enum=never,enum=when-maximised"`
342342
}
343343

pkg/gui/context/local_commits_context.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
6161
startIdx,
6262
endIdx,
6363
shouldShowGraph(c),
64-
shouldShowTags(c),
64+
shouldDisplayForScreenMode(c, viewModel.showTags),
6565
c.Model().BisectInfo,
6666
)
6767
}
@@ -149,13 +149,17 @@ type LocalCommitsViewModel struct {
149149

150150
// If this is true we'll use git log --all when fetching the commits.
151151
showWholeGitGraph bool
152+
153+
// If this is true we'll show tags in the commit list.
154+
showTags string
152155
}
153156

154157
func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *ContextCommon) *LocalCommitsViewModel {
155158
self := &LocalCommitsViewModel{
156159
ListViewModel: NewListViewModel(getModel),
157160
limitCommits: true,
158161
showWholeGitGraph: c.UserConfig().Git.Log.ShowWholeGraph,
162+
showTags: c.UserConfig().Git.Log.ShowTags,
159163
}
160164

161165
return self
@@ -239,6 +243,14 @@ func (self *LocalCommitsViewModel) SetShowWholeGitGraph(value bool) {
239243
self.showWholeGitGraph = value
240244
}
241245

246+
func (self *LocalCommitsContext) GetShowTags() string {
247+
return self.showTags
248+
}
249+
250+
func (self *LocalCommitsViewModel) SetShowTags(value string) {
251+
self.showTags = value
252+
}
253+
242254
func (self *LocalCommitsViewModel) GetShowWholeGitGraph() bool {
243255
return self.showWholeGitGraph
244256
}
@@ -248,14 +260,10 @@ func (self *LocalCommitsViewModel) GetCommits() []*models.Commit {
248260
}
249261

250262
func shouldShowGraph(c *ContextCommon) bool {
251-
return shouldShowBasedOnAppState(c, c.GetAppState().GitLogShowGraph)
252-
}
253-
254-
func shouldShowTags(c *ContextCommon) bool {
255-
return shouldShowBasedOnAppState(c, c.GetAppState().GitLogShowTags)
263+
return shouldDisplayForScreenMode(c, c.GetAppState().GitLogShowGraph)
256264
}
257265

258-
func shouldShowBasedOnAppState(c *ContextCommon, value string) bool {
266+
func shouldDisplayForScreenMode(c *ContextCommon, value string) bool {
259267
if c.Modes().Filtering.Active() {
260268
return false
261269
}

pkg/gui/context/sub_commits_context.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewSubCommitsContext(
7676
startIdx,
7777
endIdx,
7878
shouldShowGraph(c),
79-
shouldShowTags(c),
79+
shouldDisplayForScreenMode(c, viewModel.GetShowTags()),
8080
git_commands.NewNullBisectInfo(),
8181
)
8282
}
@@ -148,6 +148,7 @@ type SubCommitsViewModel struct {
148148

149149
limitCommits bool
150150
showBranchHeads bool
151+
showTags string
151152
}
152153

153154
func (self *SubCommitsViewModel) SetRef(ref types.Ref) {
@@ -174,6 +175,14 @@ func (self *SubCommitsViewModel) GetShowBranchHeads() bool {
174175
return self.showBranchHeads
175176
}
176177

178+
func (self *SubCommitsViewModel) SetShowTags(value string) {
179+
self.showTags = value
180+
}
181+
182+
func (self *SubCommitsViewModel) GetShowTags() string {
183+
return self.showTags
184+
}
185+
177186
func (self *SubCommitsContext) CanRebase() bool {
178187
return false
179188
}

pkg/gui/controllers/local_commits_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,10 +1196,10 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
11961196
Label: self.c.Tr.ShowTags,
11971197
OpensMenu: true,
11981198
OnPress: func() error {
1199-
currentValue := self.c.GetAppState().GitLogShowTags
1199+
currentValue := self.context().GetShowTags()
12001200
onPress := func(value string) func() error {
12011201
return func() error {
1202-
self.c.GetAppState().GitLogShowTags = value
1202+
self.context().SetShowTags(value)
12031203
self.c.SaveAppStateAndLogError()
12041204
self.c.PostRefreshUpdate(self.c.Contexts().LocalCommits)
12051205
self.c.PostRefreshUpdate(self.c.Contexts().SubCommits)

0 commit comments

Comments
 (0)