mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Fix deleting a remote tag when a remote branch with the same name exists, or vice versa (#5075)
Nothing to add to the PR title here. Fixes #5072.
This commit is contained in:
commit
e3ea666352
|
|
@ -5,6 +5,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type RemoteCommands struct {
|
||||
|
|
@ -52,7 +53,7 @@ func (self *RemoteCommands) UpdateRemoteUrl(remoteName string, updatedUrl string
|
|||
func (self *RemoteCommands) DeleteRemoteBranch(task gocui.Task, remoteName string, branchNames []string) error {
|
||||
cmdArgs := NewGitCmd("push").
|
||||
Arg(remoteName, "--delete").
|
||||
Arg(branchNames...).
|
||||
Arg(lo.Map(branchNames, func(b string, _ int) string { return "refs/heads/" + b })...).
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs).PromptOnCredentialRequest(task).Run()
|
||||
|
|
@ -60,7 +61,7 @@ func (self *RemoteCommands) DeleteRemoteBranch(task gocui.Task, remoteName strin
|
|||
|
||||
func (self *RemoteCommands) DeleteRemoteTag(task gocui.Task, remoteName string, tagName string) error {
|
||||
cmdArgs := NewGitCmd("push").
|
||||
Arg(remoteName, "--delete", tagName).
|
||||
Arg(remoteName, "--delete", "refs/tags/"+tagName).
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs).PromptOnCredentialRequest(task).Run()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package branch
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var DeleteRemoteBranchWhenTagWithSameNameExists = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Delete a remote branch when a remote tag with the same name exists",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.CreateLightweightTag("xyz", "HEAD")
|
||||
shell.PushBranch("origin", "HEAD:refs/tags/xyz") // abusing PushBranch to push a tag
|
||||
shell.PushBranch("origin", "HEAD:refs/heads/xyz")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Remotes().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("origin").IsSelected(),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().RemoteBranches().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
Contains("xyz"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
t.ExpectPopup().
|
||||
Confirmation().
|
||||
Title(Equals("Delete branch 'xyz'?")).
|
||||
Content(Equals("Are you sure you want to delete the remote branch 'xyz' from 'origin'?")).
|
||||
Confirm()
|
||||
|
||||
t.Views().RemoteBranches().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
|
@ -67,7 +67,6 @@ var DeleteLocalAndRemote = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
Confirm()
|
||||
}).
|
||||
IsEmpty().
|
||||
Press(keys.Universal.New).
|
||||
Tap(func() {
|
||||
t.Shell().AssertRemoteTagNotFound("origin", "new-tag")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package tag
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var DeleteRemoteTagWhenBranchWithSameNameExists = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Delete a remote tag when a remote branch with the same name exists",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CloneIntoRemote("origin")
|
||||
shell.CreateLightweightTag("xyz", "HEAD")
|
||||
shell.PushBranch("origin", "HEAD:refs/tags/xyz") // abusing PushBranch to push a tag
|
||||
shell.PushBranch("origin", "HEAD:refs/heads/xyz")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Tags().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("xyz").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.Remove)
|
||||
|
||||
t.ExpectPopup().
|
||||
Menu().
|
||||
Title(Equals("Delete tag 'xyz'?")).
|
||||
Select(Contains("Delete remote tag")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Equals("Remote from which to remove tag 'xyz':")).
|
||||
InitialText(Equals("origin")).
|
||||
SuggestionLines(
|
||||
Contains("origin"),
|
||||
).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().
|
||||
Confirmation().
|
||||
Title(Equals("Delete tag 'xyz'?")).
|
||||
Content(Equals("Are you sure you want to delete the remote tag 'xyz' from 'origin'?")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectToast(Equals("Remote tag deleted"))
|
||||
|
||||
t.Shell().AssertRemoteTagNotFound("origin", "xyz")
|
||||
},
|
||||
})
|
||||
|
|
@ -45,6 +45,7 @@ var tests = []*components.IntegrationTest{
|
|||
branch.CreateTag,
|
||||
branch.Delete,
|
||||
branch.DeleteMultiple,
|
||||
branch.DeleteRemoteBranchWhenTagWithSameNameExists,
|
||||
branch.DeleteRemoteBranchWithCredentialPrompt,
|
||||
branch.DeleteRemoteBranchWithDifferentName,
|
||||
branch.DeleteWhileFiltering,
|
||||
|
|
@ -430,6 +431,7 @@ var tests = []*components.IntegrationTest{
|
|||
tag.CrudAnnotated,
|
||||
tag.CrudLightweight,
|
||||
tag.DeleteLocalAndRemote,
|
||||
tag.DeleteRemoteTagWhenBranchWithSameNameExists,
|
||||
tag.ForceTagAnnotated,
|
||||
tag.ForceTagLightweight,
|
||||
tag.Reset,
|
||||
|
|
|
|||
Loading…
Reference in a new issue