From 53a114dd456211364f729f74918775c9133cc67b Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Thu, 10 Feb 2022 00:00:37 +0530
Subject: forge: Print current commit before running CI job.

This aids debugging especially when a job fails.

* forge/build/git.scm (hline): New function.
(download-git-to-store): Add #:show-commit? keyword argument. When
show-commit? is #t, print current commit.
* forge/forge.scm (gexp-producer->job-script): Pass #t as
#:show-commit? to latest-git-checkout.
---
 forge/build/git.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'forge/build')

diff --git a/forge/build/git.scm b/forge/build/git.scm
index 2e3dc41..444e3d6 100644
--- a/forge/build/git.scm
+++ b/forge/build/git.scm
@@ -34,7 +34,13 @@
 
 ;;; Code:
 
-(define (download-git-to-store store name url branch)
+(define (hline)
+  "Print a horizontal line 50 '=' characters long."
+  (display (make-string 50 #\=))
+  (newline)
+  (force-output))
+
+(define* (download-git-to-store store name url branch #:key show-commit?)
   "Download BRANCH of git repository from URL to STORE under NAME and
 return store path. git and certificates should be in the environment."
   (call-with-temporary-directory
@@ -48,6 +54,10 @@ return store path. git and certificates should be in the environment."
                                   (invoke-error-exit-status condition))
                           (exit #f)))
          (invoke "git" "clone" "--quiet" "--depth" "1" "--branch" branch url "."))
+       (when show-commit?
+         (hline)
+         (invoke "git" "--no-pager" "log")
+         (hline))
        (delete-file-recursively ".git"))
      (add-to-store store name #t "sha256" directory))))
 
-- 
cgit v1.2.3