Support setting the similarity threshold for detecting renames

This commit is contained in:
István Donkó
2023-09-25 17:32:12 +02:00
committed by Jesse Duffield
parent bfe2dd4ed8
commit b9107d5fc8
26 changed files with 909 additions and 618 deletions

View File

@@ -0,0 +1,41 @@
package diff
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RenameSimilarityThresholdChange = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Change the rename similarity threshold while in the commits panel",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("original", "one\ntwo\nthree\nfour\nfive\n")
shell.Commit("add original")
shell.DeleteFileAndAdd("original")
shell.CreateFileAndAdd("renamed", "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
shell.Commit("change name and contents")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().Focus()
t.Views().Main().
ContainsLines(
Contains("2 files changed, 10 insertions(+), 5 deletions(-)"),
)
t.Views().Commits().
Press(keys.Universal.DecreaseRenameSimilarityThreshold).
Tap(func() {
t.ExpectToast(Equals("Changed rename similarity threshold to 45%"))
})
t.Views().Main().
ContainsLines(
Contains("original => renamed"),
Contains("1 file changed, 5 insertions(+)"),
)
},
})

View File

@@ -0,0 +1,35 @@
package file
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RenameSimilarityThresholdChange = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Change the rename similarity threshold while in the files panel",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("original", "one\ntwo\nthree\nfour\nfive\n")
shell.Commit("add original")
shell.DeleteFileAndAdd("original")
shell.CreateFileAndAdd("renamed", "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains("D ").Contains("original"),
Contains("A ").Contains("renamed"),
).
Press(keys.Universal.DecreaseRenameSimilarityThreshold).
Tap(func() {
t.ExpectToast(Equals("Changed rename similarity threshold to 45%"))
}).
Lines(
Contains("R ").Contains("original → renamed"),
)
},
})

View File

@@ -149,6 +149,7 @@ var tests = []*components.IntegrationTest{
diff.DiffAndApplyPatch,
diff.DiffCommits,
diff.IgnoreWhitespace,
diff.RenameSimilarityThresholdChange,
file.CopyMenu,
file.DirWithUntrackedFile,
file.DiscardAllDirChanges,
@@ -161,6 +162,7 @@ var tests = []*components.IntegrationTest{
file.DiscardVariousChangesRangeSelect,
file.Gitignore,
file.RememberCommitMessageAfterFail,
file.RenameSimilarityThresholdChange,
file.StageChildrenRangeSelect,
file.StageRangeSelect,
filter_and_search.FilterCommitFiles,