mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Allow rewording and dropping commits in filtering mode
There's no reason not to allow these. Technically we could enable a few more, but I chose not to because some might be surprising or confusing in filtering mode. For example, creating a fixup commit would work (shift-F), but the newly created commit might not show up if it doesn't match the filter. Similarly, pressing `f` to fixup a commit into its parent would work, but that parent commit might not be visible, so users might expect to be fixing up into the next visible commit.
This commit is contained in:
@ -84,7 +84,7 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: opts.GetKey(opts.Config.Commits.RenameCommit),
|
Key: opts.GetKey(opts.Config.Commits.RenameCommit),
|
||||||
Handler: opts.Guards.OutsideFilterMode(self.withItem(self.reword)),
|
Handler: self.withItem(self.reword),
|
||||||
GetDisabledReason: self.require(
|
GetDisabledReason: self.require(
|
||||||
self.singleItemSelected(self.rewordEnabled),
|
self.singleItemSelected(self.rewordEnabled),
|
||||||
),
|
),
|
||||||
@ -95,7 +95,7 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: opts.GetKey(opts.Config.Commits.RenameCommitWithEditor),
|
Key: opts.GetKey(opts.Config.Commits.RenameCommitWithEditor),
|
||||||
Handler: opts.Guards.OutsideFilterMode(self.withItem(self.rewordEditor)),
|
Handler: self.withItem(self.rewordEditor),
|
||||||
GetDisabledReason: self.require(
|
GetDisabledReason: self.require(
|
||||||
self.singleItemSelected(self.rewordEnabled),
|
self.singleItemSelected(self.rewordEnabled),
|
||||||
),
|
),
|
||||||
@ -103,7 +103,7 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: opts.GetKey(opts.Config.Universal.Remove),
|
Key: opts.GetKey(opts.Config.Universal.Remove),
|
||||||
Handler: opts.Guards.OutsideFilterMode(self.withItemsRange(self.drop)),
|
Handler: self.withItemsRange(self.drop),
|
||||||
GetDisabledReason: self.require(
|
GetDisabledReason: self.require(
|
||||||
self.itemRangeSelected(
|
self.itemRangeSelected(
|
||||||
self.canDropCommits,
|
self.canDropCommits,
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package filter_by_path
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var DropCommitInFilteringMode = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Filter commits by file path, then drop a commit",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
commonSetup(shell)
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
filterByFilterFile(t, keys)
|
||||||
|
|
||||||
|
t.Views().Commits().
|
||||||
|
IsFocused().
|
||||||
|
Lines(
|
||||||
|
Contains(`both files`).IsSelected(),
|
||||||
|
Contains(`only filterFile`),
|
||||||
|
).
|
||||||
|
Press(keys.Universal.Remove).
|
||||||
|
Tap(func() {
|
||||||
|
t.ExpectPopup().Confirmation().
|
||||||
|
Title(Equals("Drop commit")).
|
||||||
|
Content(Equals("Are you sure you want to drop the selected commit(s)?")).
|
||||||
|
Confirm()
|
||||||
|
}).
|
||||||
|
Lines(
|
||||||
|
Contains(`only filterFile`).IsSelected(),
|
||||||
|
).
|
||||||
|
Press(keys.Universal.Return).
|
||||||
|
Lines(
|
||||||
|
Contains(`none of the two`),
|
||||||
|
Contains(`only otherFile`),
|
||||||
|
Contains(`only filterFile`).IsSelected(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
@ -0,0 +1,46 @@
|
|||||||
|
package filter_by_path
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RewordCommitInFilteringMode = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Filter commits by file path, then reword a commit",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
commonSetup(shell)
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
filterByFilterFile(t, keys)
|
||||||
|
|
||||||
|
t.Views().Commits().
|
||||||
|
IsFocused().
|
||||||
|
Lines(
|
||||||
|
Contains(`both files`).IsSelected(),
|
||||||
|
Contains(`only filterFile`),
|
||||||
|
).
|
||||||
|
SelectNextItem().
|
||||||
|
Press(keys.Commits.RenameCommit).
|
||||||
|
Tap(func() {
|
||||||
|
t.ExpectPopup().CommitMessagePanel().
|
||||||
|
Clear().
|
||||||
|
Type("new message").
|
||||||
|
Confirm()
|
||||||
|
}).
|
||||||
|
Lines(
|
||||||
|
Contains(`both files`),
|
||||||
|
Contains(`new message`).IsSelected(),
|
||||||
|
).
|
||||||
|
Press(keys.Universal.Return).
|
||||||
|
Lines(
|
||||||
|
Contains(`none of the two`),
|
||||||
|
Contains(`both files`),
|
||||||
|
Contains(`only otherFile`),
|
||||||
|
Contains(`new message`).IsSelected(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
@ -233,7 +233,9 @@ var tests = []*components.IntegrationTest{
|
|||||||
filter_by_author.SelectAuthor,
|
filter_by_author.SelectAuthor,
|
||||||
filter_by_author.TypeAuthor,
|
filter_by_author.TypeAuthor,
|
||||||
filter_by_path.CliArg,
|
filter_by_path.CliArg,
|
||||||
|
filter_by_path.DropCommitInFilteringMode,
|
||||||
filter_by_path.KeepSameCommitSelectedOnExit,
|
filter_by_path.KeepSameCommitSelectedOnExit,
|
||||||
|
filter_by_path.RewordCommitInFilteringMode,
|
||||||
filter_by_path.SelectFile,
|
filter_by_path.SelectFile,
|
||||||
filter_by_path.ShowDiffsForRenamedFile,
|
filter_by_path.ShowDiffsForRenamedFile,
|
||||||
filter_by_path.TypeFile,
|
filter_by_path.TypeFile,
|
||||||
|
Reference in New Issue
Block a user