diff --git a/pkg/integration/components/git.go b/pkg/integration/components/git.go index b9b3dcc46..4f1933efa 100644 --- a/pkg/integration/components/git.go +++ b/pkg/integration/components/git.go @@ -14,6 +14,10 @@ func (self *Git) CurrentBranchName(expectedName string) *Git { return self.assert("git rev-parse --abbrev-ref HEAD", expectedName) } +func (self *Git) TagNamesAt(ref string, expectedNames []string) *Git { + return self.assert(fmt.Sprintf(`git tag --contains "%s"`, ref), strings.Join(expectedNames, "\n")) +} + func (self *Git) assert(cmdStr string, expected string) *Git { self.assertWithRetries(func() (bool, string) { output, err := self.shell.runCommandWithOutput(cmdStr) diff --git a/pkg/integration/tests/branch/create_tag.go b/pkg/integration/tests/branch/create_tag.go new file mode 100644 index 000000000..4742d8a34 --- /dev/null +++ b/pkg/integration/tests/branch/create_tag.go @@ -0,0 +1,47 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Create a new tag on branch", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + NewBranch("new-branch"). + EmptyCommit("new commit") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Lines( + MatchesRegexp(`\*\s*new-branch`).IsSelected(), + MatchesRegexp(`master`), + ). + SelectNextItem(). + Press(keys.Branches.CreateTag) + + t.ExpectPopup().Menu(). + Title(Equals("Create tag")). + Confirm() + + t.ExpectPopup().Prompt(). + Title(Equals("Tag name:")). + Type("new-tag"). + Confirm() + + t.Views().Tags(). + Lines( + MatchesRegexp(`new-tag`).IsSelected(), + ) + + t.Git(). + TagNamesAt("HEAD", []string{}). + TagNamesAt("master", []string{"new-tag"}) + }, +}) diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go index 2be0b902c..5d831900e 100644 --- a/pkg/integration/tests/tests_gen.go +++ b/pkg/integration/tests/tests_gen.go @@ -27,6 +27,7 @@ var tests = []*components.IntegrationTest{ bisect.Basic, bisect.FromOtherBranch, branch.CheckoutByName, + branch.CreateTag, branch.Delete, branch.DetachedHead, branch.OpenWithCliArg,