From 0b55eaca1d3d2b52df0531ca2da613fabb799c18 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 20 Feb 2023 18:52:45 +1100 Subject: add create tag from commit test --- pkg/config/user_config.go | 4 +- pkg/gui/controllers/local_commits_controller.go | 2 +- pkg/integration/tests/commit/create_tag.go | 51 +++++++++++++++++++++++++ pkg/integration/tests/tests_gen.go | 1 + 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 pkg/integration/tests/commit/create_tag.go diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index d9e736149..6fe880ce2 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -258,7 +258,7 @@ type KeybindingCommitsConfig struct { CherryPickCopy string `yaml:"cherryPickCopy"` CherryPickCopyRange string `yaml:"cherryPickCopyRange"` PasteCommits string `yaml:"pasteCommits"` - TagCommit string `yaml:"tagCommit"` + CreateTag string `yaml:"tagCommit"` CheckoutCommit string `yaml:"checkoutCommit"` ResetCherryPick string `yaml:"resetCherryPick"` CopyCommitAttributeToClipboard string `yaml:"copyCommitAttributeToClipboard"` @@ -544,7 +544,7 @@ func GetDefaultConfig() *UserConfig { CherryPickCopy: "c", CherryPickCopyRange: "C", PasteCommits: "v", - TagCommit: "T", + CreateTag: "T", CheckoutCommit: "", ResetCherryPick: "", CopyCommitAttributeToClipboard: "y", diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index a9fe7a190..ae0f342fb 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -132,7 +132,7 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ Description: self.c.Tr.LcRevertCommit, }, { - Key: opts.GetKey(opts.Config.Commits.TagCommit), + Key: opts.GetKey(opts.Config.Commits.CreateTag), Handler: self.checkSelected(self.createTag), Description: self.c.Tr.LcTagCommit, }, diff --git a/pkg/integration/tests/commit/create_tag.go b/pkg/integration/tests/commit/create_tag.go new file mode 100644 index 000000000..4b749b235 --- /dev/null +++ b/pkg/integration/tests/commit/create_tag.go @@ -0,0 +1,51 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Create a new tag on a commit", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("one") + shell.EmptyCommit("two") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("two").IsSelected(), + Contains("one"), + ). + Press(keys.Commits.CreateTag) + + t.ExpectPopup().Menu(). + Title(Equals("Create tag")). + Select(Contains("lightweight")). + Confirm() + + t.ExpectPopup().Prompt(). + Title(Equals("Tag name:")). + Type("new-tag"). + Confirm() + + t.Views().Commits(). + Lines( + MatchesRegexp(`new-tag.*two`).IsSelected(), + MatchesRegexp(`one`), + ) + + t.Views().Tags(). + Focus(). + Lines( + MatchesRegexp(`new-tag.*two`).IsSelected(), + ) + + t.Git(). + TagNamesAt("HEAD", []string{"new-tag"}) + }, +}) diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go index 639a7743c..e2336f6be 100644 --- a/pkg/integration/tests/tests_gen.go +++ b/pkg/integration/tests/tests_gen.go @@ -41,6 +41,7 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPickConflicts, commit.Commit, commit.CommitMultiline, + commit.CreateTag, commit.DiscardOldFileChange, commit.NewBranch, commit.Revert, -- cgit v1.2.3