1+ # ── BaseModelica.jl version helpers ────────────────────────────────────────────
2+
3+ """
4+ _bm_sha() → String
5+
6+ Return the first 7 characters of the git commit SHA for the installed
7+ BaseModelica.jl package by resolving the package's tree SHA against the
8+ cached git clone in the Julia depot. Falls back to the tree SHA when the
9+ clone cannot be found, and returns `""` for registry installs (no git
10+ metadata available) or when the SHA cannot be determined.
11+ """
12+ function _bm_sha ():: String
13+ try
14+ for (_, info) in Pkg. dependencies ()
15+ info. name == " BaseModelica" || continue
16+ tree_sha = info. tree_hash
17+ tree_sha === nothing && return " "
18+
19+ # Resolve the tree SHA to a commit SHA via the cached git clone.
20+ git_source = info. git_source
21+ if git_source != = nothing
22+ for depot in Base. DEPOT_PATH
23+ clones_dir = joinpath (depot, " clones" )
24+ @show clones_dir
25+ isdir (clones_dir) || continue
26+ for clone in readdir (clones_dir; join= true )
27+ isdir (clone) || continue
28+ try
29+ remote = strip (readchomp (` git -C $clone remote get-url origin` ))
30+ (remote == git_source || remote * " .git" == git_source ||
31+ git_source * " .git" == remote) || continue
32+ fmt = " %H %T"
33+ log = readchomp (` git -C $clone log --all --format=$fmt ` )
34+ for line in split (log, ' \n ' )
35+ parts = split (strip (line))
36+ length (parts) == 2 && parts[2 ] == tree_sha || continue
37+ sha = parts[1 ]
38+ return sha[1 : min (7 , length (sha))]
39+ end
40+ catch
41+ end
42+ end
43+ end
44+ end
45+
46+ # Fall back to the tree SHA when no clone is found.
47+ return tree_sha[1 : min (7 , length (tree_sha))]
48+ end
49+ catch
50+ end
51+ return " "
52+ end
53+
154# ── Per-model orchestrator ─────────────────────────────────────────────────────
255
356"""
@@ -69,8 +122,17 @@ function main(;
69122)
70123 t0 = time ()
71124
125+ # Set up working directory
126+ bm_version = get (ENV , " BM_VERSION" , string (pkgversion (BaseModelica)))
127+ bm_sha = _bm_sha ()
128+ @info " Testing BaseModelica.jl version $(bm_version) ($(bm_sha) )"
129+
72130 if isempty (results_root)
73- results_root = joinpath (library, version)
131+ if bm_version == " main"
132+ results_root = joinpath (" results" , bm_sha, library, version)
133+ else
134+ results_root = joinpath (" results" , bm_version, library, version)
135+ end
74136 end
75137 results_root = abspath (results_root)
76138 mkpath (joinpath (results_root, " files" ))
@@ -142,8 +204,6 @@ function main(;
142204 end
143205
144206 cpu_info = Sys. cpu_info ()
145- bm_ver_env = get (ENV , " BM_VERSION" , " " )
146- bm_version = isempty (bm_ver_env) ? string (pkgversion (BaseModelica)) : bm_ver_env
147207 info = RunInfo (
148208 library,
149209 version,
@@ -154,6 +214,7 @@ function main(;
154214 ref_root,
155215 omc_version,
156216 bm_version,
217+ bm_sha,
157218 isempty (cpu_info) ? " unknown" : strip (cpu_info[1 ]. model),
158219 length (cpu_info),
159220 Sys. total_memory () / 1024 ^ 3 ,
0 commit comments