termui: add git fetch --prune before calculating cherry-pick refs
This change adds a best-effort git fetch --prune before resolving git refs
in the getGitRefName function. This ensures that the cherry-pick command
displayed to the user at the end of a session uses up-to-date refs rather
than potentially stale ones.
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/termui/termui.go b/termui/termui.go
index 5a3eca3..c7d0991 100644
--- a/termui/termui.go
+++ b/termui/termui.go
@@ -421,6 +421,9 @@
// getGitRefName returns a readable git ref for sha, falling back to the original sha on error.
func getGitRefName(sha string) string {
+ // Best-effort git fetch --prune to ensure we have the latest refs
+ exec.Command("git", "fetch", "--prune").Run()
+
// local branch or tag name
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", sha)
branchName, err := cmd.Output()