mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-06-20 01:19:23 +02:00
Fix checking out a tag when there is a branch with the same name (#3179)
This commit is contained in:
@@ -83,7 +83,7 @@ func (self *TagsController) GetOnRenderToMain() func() error {
|
|||||||
|
|
||||||
func (self *TagsController) checkout(tag *models.Tag) error {
|
func (self *TagsController) checkout(tag *models.Tag) error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.CheckoutTag)
|
self.c.LogAction(self.c.Tr.Actions.CheckoutTag)
|
||||||
if err := self.c.Helpers().Refs.CheckoutRef(tag.Name, types.CheckoutRefOptions{}); err != nil {
|
if err := self.c.Helpers().Refs.CheckoutRef(tag.FullRefName(), types.CheckoutRefOptions{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return self.c.PushContext(self.c.Contexts().Branches)
|
return self.c.PushContext(self.c.Contexts().Branches)
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package tag
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var CheckoutWhenBranchWithSameNameExists = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Checkout a tag when there's a branch with the same name",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.EmptyCommit("one")
|
||||||
|
shell.NewBranch("tag")
|
||||||
|
shell.Checkout("master")
|
||||||
|
shell.EmptyCommit("two")
|
||||||
|
shell.CreateLightweightTag("tag", "HEAD")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Tags().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
Contains("tag").IsSelected(),
|
||||||
|
).
|
||||||
|
PressPrimaryAction() // checkout tag
|
||||||
|
|
||||||
|
t.Views().Branches().IsFocused().Lines(
|
||||||
|
Contains("HEAD detached at tag").IsSelected(),
|
||||||
|
Contains("master"),
|
||||||
|
Contains("tag"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -245,6 +245,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
sync.PushWithCredentialPrompt,
|
sync.PushWithCredentialPrompt,
|
||||||
sync.RenameBranchAndPull,
|
sync.RenameBranchAndPull,
|
||||||
tag.Checkout,
|
tag.Checkout,
|
||||||
|
tag.CheckoutWhenBranchWithSameNameExists,
|
||||||
tag.CreateWhileCommitting,
|
tag.CreateWhileCommitting,
|
||||||
tag.CrudAnnotated,
|
tag.CrudAnnotated,
|
||||||
tag.CrudLightweight,
|
tag.CrudLightweight,
|
||||||
|
|||||||
Reference in New Issue
Block a user