From e427378736e9cc5c4d1f28dc90a35752799406cd Mon Sep 17 00:00:00 2001
From: Hidde Beydals <hidde@hhh.computer>
Date: Wed, 18 Sep 2024 15:59:19 +0200
Subject: [PATCH] fix(directives): check for `nil` commit in `git-clone`

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
---
 internal/directives/git_clone_directive.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/internal/directives/git_clone_directive.go b/internal/directives/git_clone_directive.go
index bda437e63..ac081247b 100644
--- a/internal/directives/git_clone_directive.go
+++ b/internal/directives/git_clone_directive.go
@@ -140,6 +140,10 @@ func (g *gitCloneDirective) run(
 				return Result{Status: StatusFailure},
 					fmt.Errorf("error finding commit from repo %s: %w", cfg.RepoURL, err)
 			}
+			if commit == nil {
+				return Result{Status: StatusFailure},
+					fmt.Errorf("could not find any commit from repo %s", cfg.RepoURL)
+			}
 			ref = commit.ID
 		case checkout.Tag != "":
 			ref = checkout.Tag