1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

Allow deleting remote tags/branches from local tag/branch views (#2738)

This commit is contained in:
Federico
2023-08-10 09:39:26 +02:00
committed by GitHub
parent c43830b027
commit 0df5cb1286
35 changed files with 487 additions and 158 deletions

View File

@ -18,14 +18,28 @@ func (self *Git) TagNamesAt(ref string, expectedNames []string) *Git {
return self.assert([]string{"git", "tag", "--sort=v:refname", "--points-at", ref}, strings.Join(expectedNames, "\n"))
}
func (self *Git) RemoteTagDeleted(ref string, tagName string) *Git {
return self.expect([]string{"git", "ls-remote", ref, fmt.Sprintf("refs/tags/%s", tagName)}, func(s string) (bool, string) {
return len(s) == 0, fmt.Sprintf("Expected tag %s to have been removed from %s", tagName, ref)
})
}
func (self *Git) assert(cmdArgs []string, expected string) *Git {
self.expect(cmdArgs, func(output string) (bool, string) {
return output == expected, fmt.Sprintf("Expected current branch name to be '%s', but got '%s'", expected, output)
})
return self
}
func (self *Git) expect(cmdArgs []string, condition func(string) (bool, string)) *Git {
self.assertWithRetries(func() (bool, string) {
output, err := self.shell.runCommandWithOutput(cmdArgs)
if err != nil {
return false, fmt.Sprintf("Unexpected error running command: `%v`. Error: %s", cmdArgs, err.Error())
}
actual := strings.TrimSpace(output)
return actual == expected, fmt.Sprintf("Expected current branch name to be '%s', but got '%s'", expected, actual)
return condition(actual)
})
return self