diff --git a/docs/Config.md b/docs/Config.md index afc17b723..b165239c0 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -72,6 +72,9 @@ gui: # When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS. mouseEvents: true + # If true, do not show a warning when amending a commit. + skipAmendWarning: false + # If true, do not show a warning when discarding changes in the staging view. skipDiscardChangeWarning: false diff --git a/pkg/config/app_config_test.go b/pkg/config/app_config_test.go index 90c13ce6c..1241230d0 100644 --- a/pkg/config/app_config_test.go +++ b/pkg/config/app_config_test.go @@ -384,6 +384,9 @@ gui: # When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS. mouseEvents: true + # If true, do not show a warning when amending a commit. + skipAmendWarning: false + # If true, do not show a warning when discarding changes in the staging view. skipDiscardChangeWarning: false diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index af80dd9a4..f97bb33ce 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -74,6 +74,8 @@ type GuiConfig struct { // If true, capture mouse events. // When mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS. MouseEvents bool `yaml:"mouseEvents"` + // If true, do not show a warning when amending a commit. + SkipAmendWarning bool `yaml:"skipAmendWarning"` // If true, do not show a warning when discarding changes in the staging view. SkipDiscardChangeWarning bool `yaml:"skipDiscardChangeWarning"` // If true, do not show warning when applying/popping the stash @@ -734,6 +736,7 @@ func GetDefaultConfig() *UserConfig { ScrollOffBehavior: "margin", TabWidth: 4, MouseEvents: true, + SkipAmendWarning: false, SkipDiscardChangeWarning: false, SkipStashWarning: false, SidePanelWidth: 0.3333, diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 211232b13..d10d4726a 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -795,7 +795,7 @@ func (self *FilesController) handleAmendCommitPress() error { }, }, }) - } else { + } else if !self.c.UserConfig().Gui.SkipAmendWarning { self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AmendLastCommitTitle, Prompt: self.c.Tr.SureToAmend, @@ -803,9 +803,11 @@ func (self *FilesController) handleAmendCommitPress() error { return doAmend() }, }) + + return nil } - return nil + return doAmend() } func (self *FilesController) isResolvingConflicts() bool { diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index e9cd9cbc0..321db56c9 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -717,27 +717,19 @@ func (self *LocalCommitsController) moveUp(selectedCommits []*models.Commit, sta } func (self *LocalCommitsController) amendTo(commit *models.Commit) error { + var handleCommit func() error + if self.isSelectedHeadCommit() { - self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.AmendCommitTitle, - Prompt: self.c.Tr.AmendCommitPrompt, - HandleConfirm: func() error { - return self.c.Helpers().WorkingTree.WithEnsureCommittableFiles(func() error { - if err := self.c.Helpers().AmendHelper.AmendHead(); err != nil { - return err - } - return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) - }) - }, - }) - - return nil - } - - self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.AmendCommitTitle, - Prompt: self.c.Tr.AmendCommitPrompt, - HandleConfirm: func() error { + handleCommit = func() error { + return self.c.Helpers().WorkingTree.WithEnsureCommittableFiles(func() error { + if err := self.c.Helpers().AmendHelper.AmendHead(); err != nil { + return err + } + return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) + }) + } + } else { + handleCommit = func() error { return self.c.Helpers().WorkingTree.WithEnsureCommittableFiles(func() error { return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func(gocui.Task) error { self.c.LogAction(self.c.Tr.Actions.AmendCommit) @@ -745,7 +737,17 @@ func (self *LocalCommitsController) amendTo(commit *models.Commit) error { return self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err) }) }) - }, + } + } + + if self.c.UserConfig().Gui.SkipAmendWarning { + return handleCommit() + } + + self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.AmendCommitTitle, + Prompt: self.c.Tr.AmendCommitPrompt, + HandleConfirm: handleCommit, }) return nil diff --git a/schema/config.json b/schema/config.json index 9560c3ab4..5b33dfd01 100644 --- a/schema/config.json +++ b/schema/config.json @@ -468,6 +468,11 @@ "description": "If true, capture mouse events.\nWhen mouse events are captured, it's a little harder to select text: e.g. requiring you to hold the option key when on macOS.", "default": true }, + "skipAmendWarning": { + "type": "boolean", + "description": "If true, do not show a warning when amending a commit.", + "default": false + }, "skipDiscardChangeWarning": { "type": "boolean", "description": "If true, do not show a warning when discarding changes in the staging view.",