From e3245182f12342148442f9e2cda6604c2b2e7633 Mon Sep 17 00:00:00 2001
From: Daniel Vedder <daniel.vedder@idiv.de>
Date: Sat, 21 Jan 2023 18:32:17 +0100
Subject: [PATCH] Added a clean-repo check to the output.

---
 src/core/output.jl | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/core/output.jl b/src/core/output.jl
index d0d7626..c9deaac 100644
--- a/src/core/output.jl
+++ b/src/core/output.jl
@@ -46,13 +46,17 @@ function setupdatadir(model::AgentBasedModel)
     # Export a copy of the current parameter settings to the output folder.
     # This can be used to replicate this exact run in future, and also
     # records the current time and git commit.
-    #TODO check if there have been changes to the repository since the last
-    # commit, as this may impact replicability
+    currentcommit = read(`git rev-parse HEAD`, String)[1:8]
     open(joinpath(@param(core.outdir), basename(@param(core.configfile))), "w") do f
         println(f, "#\n# --- Persephone configuration parameters ---")
         println(f, "# This file was generated automatically.")
         println(f, "# Simulation run on $(string(Dates.format(Dates.now(), "d u Y HH:MM:SS"))),")
-        println(f, "# with git commit $(read(`git rev-parse HEAD`, String))#\n")
+        println(f, "# with Persephone $(pkgversion(Persephone)), git commit $(currentcommit),")
+        println(f, "# running on Julia $(VERSION) with Agents.jl $(pkgversion(Agents)).\n#\n")
+        if !isempty(strip(read(`git status -s`, String)))
+            println(f, "# WARNING: Your repository contains uncommitted changes. This may")
+            println(f, "#          compromise the reproducibility of this simulation run.\n")
+        end
         TOML.print(f, model.settings)
     end
     # Copy the map files to the output folder
-- 
GitLab