Skip to content

Commit

Permalink
Remove return value of OpenCommitMessagePanel
Browse files Browse the repository at this point in the history
Similar to the previous commit: in 100% of the call sites we now need an extra
`return nil`. Nevertheless, I still prefer it this way.
  • Loading branch information
stefanhaller committed Sep 5, 2024
1 parent 9cbe6cd commit 5142dc6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion pkg/gui/controllers/custom_patch_options_menu_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
self.returnFocusFromPatchExplorerIfNecessary()

commitIndex := self.getPatchCommitIndex()
return self.c.Helpers().Commits.OpenCommitMessagePanel(
self.c.Helpers().Commits.OpenCommitMessagePanel(
&helpers.OpenCommitMessagePanelOpts{
// Pass a commit index of one less than the moved-from commit, so that
// you can press up arrow once to recall the original commit message:
Expand All @@ -219,6 +219,8 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
},
},
)

return nil
}

func (self *CustomPatchOptionsMenuAction) handleApplyPatch(reverse bool) error {
Expand Down
3 changes: 1 addition & 2 deletions pkg/gui/controllers/helpers/commits_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ type OpenCommitMessagePanelOpts struct {
InitialMessage string
}

func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOpts) error {
func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOpts) {
onConfirm := func(summary string, description string) error {
self.CloseCommitMessagePanel()

Expand All @@ -150,7 +150,6 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp
self.UpdateCommitPanelView(opts.InitialMessage)

self.c.Context().Push(self.c.Contexts().CommitMessage)
return nil
}

func (self *CommitsHelper) OnCommitSuccess() {
Expand Down
4 changes: 3 additions & 1 deletion pkg/gui/controllers/helpers/tags_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
return doCreateTag(tagName, description, false)
}

return self.commitsHelper.OpenCommitMessagePanel(
self.commitsHelper.OpenCommitMessagePanel(
&OpenCommitMessagePanelOpts{
CommitIndex: context.NoCommitIndex,
InitialMessage: "",
Expand All @@ -76,4 +76,6 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
OnConfirm: onConfirm,
},
)

return nil
}
4 changes: 3 additions & 1 deletion pkg/gui/controllers/helpers/working_tree_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (self *WorkingTreeHelper) OpenMergeTool() error {

func (self *WorkingTreeHelper) HandleCommitPressWithMessage(initialMessage string) error {
return self.WithEnsureCommitableFiles(func() error {
return self.commitsHelper.OpenCommitMessagePanel(
self.commitsHelper.OpenCommitMessagePanel(
&OpenCommitMessagePanelOpts{
CommitIndex: context.NoCommitIndex,
InitialMessage: initialMessage,
Expand All @@ -99,6 +99,8 @@ func (self *WorkingTreeHelper) HandleCommitPressWithMessage(initialMessage strin
OnSwitchToEditor: self.switchFromCommitMessagePanelToEditor,
},
)

return nil
})
}

Expand Down
8 changes: 6 additions & 2 deletions pkg/gui/controllers/local_commits_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error {
if self.c.UserConfig().Git.Commit.AutoWrapCommitMessage {
commitMessage = helpers.TryRemoveHardLineBreaks(commitMessage, self.c.UserConfig().Git.Commit.AutoWrapWidth)
}
return self.c.Helpers().Commits.OpenCommitMessagePanel(
self.c.Helpers().Commits.OpenCommitMessagePanel(
&helpers.OpenCommitMessagePanelOpts{
CommitIndex: self.context().GetSelectedLineIdx(),
InitialMessage: commitMessage,
Expand All @@ -377,6 +377,8 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error {
OnSwitchToEditor: self.switchFromCommitMessagePanelToEditor,
},
)

return nil
}

func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepath string) error {
Expand Down Expand Up @@ -931,7 +933,7 @@ func (self *LocalCommitsController) createAmendCommit(commit *models.Commit, inc
commitMessage = helpers.TryRemoveHardLineBreaks(commitMessage, self.c.UserConfig().Git.Commit.AutoWrapWidth)
}
originalSubject, _, _ := strings.Cut(commitMessage, "\n")
return self.c.Helpers().Commits.OpenCommitMessagePanel(
self.c.Helpers().Commits.OpenCommitMessagePanel(
&helpers.OpenCommitMessagePanelOpts{
CommitIndex: self.context().GetSelectedLineIdx(),
InitialMessage: commitMessage,
Expand All @@ -952,6 +954,8 @@ func (self *LocalCommitsController) createAmendCommit(commit *models.Commit, inc
OnSwitchToEditor: nil,
},
)

return nil
}

func (self *LocalCommitsController) squashFixupCommits() error {
Expand Down

0 comments on commit 5142dc6

Please sign in to comment.