From e3d21989712ead11e5d768fc867a6c369f796a3e Mon Sep 17 00:00:00 2001 From: Erik Jankovic Date: Wed, 23 Apr 2025 17:34:44 +0200 Subject: [PATCH] fix: fetch remote ref during git update Signed-off-by: Erik Jankovic --- get_git.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/get_git.go b/get_git.go index 636d5c737..40d4fc3a4 100644 --- a/get_git.go +++ b/get_git.go @@ -267,6 +267,11 @@ func (g *GitGetter) update(ctx context.Context, dst, sshKeyFile string, u *url.U return err } + // If the ref is empty, we need to find the default branch, otherwise fetch command will fail + if ref == "" { + ref = findRemoteDefaultBranch(ctx, u) + } + // Fetch the remote ref cmd = exec.CommandContext(ctx, "git", "fetch", "origin", "--", ref) cmd.Dir = dst