From 5c8c89b2fa5bbb8ae816c68e8134f467bbb67337 Mon Sep 17 00:00:00 2001
From: Daniel Vedder <daniel.vedder@idiv.de>
Date: Tue, 10 Sep 2024 20:13:59 +0200
Subject: [PATCH] Fixed git related error in saveinputdata()

---
 src/core/output.jl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/core/output.jl b/src/core/output.jl
index 4144d8f..c545317 100644
--- a/src/core/output.jl
+++ b/src/core/output.jl
@@ -88,7 +88,11 @@ settings used. This allows replicating a run in future.
 function saveinputfiles(model::SimulationModel)
     #XXX If this is a parallel run, we should save the global config to the top-level
     # output directory
-    currentcommit = read(`git rev-parse HEAD`, String)[1:8]
+    try # if this is loaded as a package, the directory may not be a git repo
+        currentcommit = read(`git rev-parse HEAD`, String)[1:8]
+    catch
+        currentcommit = "********"
+    end
     mkpath(joinpath(@param(core.outdir), RECORDDIR))
     open(joinpath(@param(core.outdir), RECORDDIR, basename(@param(core.configfile))), "w") do f
         println(f, "#\n# --- Persefone configuration parameters ---")
-- 
GitLab