Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions pkg/config/app_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an explicit initialization to false in the GetDefaultConfig function below, like we do for the other Skip* options. Not technically needed, but it's good to be explicit for these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catches! I've just pushed those changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I took the liberty of squashing the second commit into the first. In the future you might consider using fixup! commits in such cases.

// 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
Expand Down Expand Up @@ -734,6 +736,7 @@ func GetDefaultConfig() *UserConfig {
ScrollOffBehavior: "margin",
TabWidth: 4,
MouseEvents: true,
SkipAmendWarning: false,
SkipDiscardChangeWarning: false,
SkipStashWarning: false,
SidePanelWidth: 0.3333,
Expand Down
6 changes: 4 additions & 2 deletions pkg/gui/controllers/files_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,17 +795,19 @@ 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,
HandleConfirm: func() error {
return doAmend()
},
})

return nil
}

return nil
return doAmend()
}

func (self *FilesController) isResolvingConflicts() bool {
Expand Down
44 changes: 23 additions & 21 deletions pkg/gui/controllers/local_commits_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,35 +717,37 @@ func (self *LocalCommitsController) moveUp(selectedCommits []*models.Commit, sta
}

func (self *LocalCommitsController) amendTo(commit *models.Commit) 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})
})
},
})
var handleCommit func() error

return nil
}

self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.AmendCommitTitle,
Prompt: self.c.Tr.AmendCommitPrompt,
HandleConfirm: func() error {
if self.isSelectedHeadCommit() {
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)
err := self.c.Git().Rebase.AmendTo(self.c.Model().Commits, self.context().GetView().SelectedLineIdx())
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
Expand Down
5 changes: 5 additions & 0 deletions schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down