lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Add option to turn off prompt on commit reword in editor

Open Tej12345 opened this issue 2 years ago • 4 comments

I would like to have an option to disable prompt: "Are you sure you want to reword this commit in your editor" It's really annoying when you reword like 50 commits. Code hints: RewordInEditorPrompt

func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error {
	applied, err := self.handleMidRebaseCommand("reword", commit)
	if err != nil {
		return err
	}
	if applied {
		return nil
	}

	return self.c.Confirm(types.ConfirmOpts{
		Title:  self.c.Tr.RewordInEditorTitle,
		Prompt: self.c.Tr.RewordInEditorPrompt,
		HandleConfirm: func() error {
			self.c.LogAction(self.c.Tr.Actions.RewordCommit)
			subProcess, err := self.git.Rebase.RewordCommitInEditor(
				self.model.Commits, self.context().GetSelectedLineIdx(),
			)
			if err != nil {
				return self.c.Error(err)
			}
			if subProcess != nil {
				return self.c.RunSubprocessAndRefresh(subProcess)
			}

			return nil
		},
	})
}

Tej12345 avatar Jul 12 '22 11:07 Tej12345

@jesseduffield what if we put the rewords behind a menu? r for ordinary reword, R for rewording through an editor, and then we wouldn't need the confirmation?

That would be bit of a breaking change, but anyone really mind?

mark2185 avatar Jul 12 '22 19:07 mark2185

@mark2185 I'm inclined to wrap it in a menu, however, that won't solve this issue which is related to the number of keypresses, because the keypress count remains the same.

jesseduffield avatar Jul 15 '22 07:07 jesseduffield

because the keypress count remains the same.

Got me there.

How is this usually done through the CLI? I seem to recall something like all of the commit messages are opened in the editor, maybe we could introduce a reword option for the visual selection of commits?

mark2185 avatar Jul 15 '22 08:07 mark2185

I guess if you want to reword a heap of commits in quick succession you'd use a rebase with each line having an 'edit' action (that's just off the top of my head).

jesseduffield avatar Jul 15 '22 08:07 jesseduffield

Related feature request: I want to reword a single commit with no prompt

Even if you solve the bulk case separately, I still don't want the prompt. My workflow involves a lot of rewording.

The extra keypress isn't a big deal, but I don't like training myself to mindlessly ignore prompts. One of the things I like a lot about lazygit is that it smooths git's rough edges, and one of the ways it does that is by adding prompts when you want to think hard about what you're doing.

dzfranklin avatar Oct 05 '22 21:10 dzfranklin