diff --git a/src/core/output.jl b/src/core/output.jl index d0d76261160e72d687c824fbce6204d76b315507..c9deaac6772c303684e5ef8939db55622468c173 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