diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-21 01:18:21 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-21 01:18:21 -0400 |
commit | fe73a9d176f502feb454fde8c328d5ed761f50ff (patch) | |
tree | 07476d0b0f60a6c1dc760d3c3ed474008f4e9be8 /source/merge.d | |
parent | dee2bb287820edd24ca38c678a45295426cb2b28 (diff) | |
download | dm-fe73a9d176f502feb454fde8c328d5ed761f50ff.tar.gz |
A bit more work
Diffstat (limited to 'source/merge.d')
-rw-r--r-- | source/merge.d | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/source/merge.d b/source/merge.d index 919a577..4f3caea 100644 --- a/source/merge.d +++ b/source/merge.d @@ -1,12 +1,17 @@ module merge; -import std.stdio; -import std.string; +import std.algorithm; import std.array; +import std.conv : to; +import std.file; import std.format; import std.typecons; -import std.file; +import std.path; +import std.range; import std.regex; +import std.stdio; +import std.string; import conda; +import dyaml : dumper, Loader, Node; auto RE_COMMENT = regex(r"[;#]"); @@ -19,6 +24,7 @@ string safe_spec(string s) { return "'" ~ s ~ "'"; } + string safe_install(string[] specs) { string[] result; foreach (record; specs) { @@ -27,6 +33,7 @@ string safe_install(string[] specs) { return result.join(" "); } + string[string][] dmfile(string filename) { string[string][] results; foreach (line; File(filename).byLine()) { @@ -48,6 +55,7 @@ string[string][] dmfile(string filename) { return results; } + bool env_combine(ref Conda conda, string name, string specfile, string mergefile) { if (indexOf(specfile, "://", 0) < 0 && !specfile.exists) { throw new Exception(specfile ~ " does not exist"); @@ -81,3 +89,45 @@ bool env_combine(ref Conda conda, string name, string specfile, string mergefile } return true; } + + +string[string][] testable_packages(ref Conda conda, string mergefile) { + string[string][] results; + foreach (record; dmfile(mergefile)) { + string[] found_packages = conda.scan_packages(record["name"] + ~ "-" + ~ record["version"] + ~ "*"); + string pkg = found_packages[$-1]; + string pkg_d = chainPath(conda.install_prefix, + "pkgs", + pkg).array; + string info_d = chainPath(pkg_d, "info").array; + string recipe_d = chainPath(info_d, "recipe").array; + string git_log = chainPath(info_d, "git").array; + string recipe = chainPath(recipe_d, "meta.yaml").array; + string repository; + string head; + string[] logdata; + Node meta; + + if (!git_log.exists) { + continue; + } + + foreach (line; File(git_log).byLine) { + logdata ~= line.dup; + } + + if (logdata.empty) { + continue; + } + + head = logdata[1].split()[1]; + meta = Loader.fromFile(recipe).load(); + repository = meta["source"]["git_url"].as!string; + + results ~= ["repo": repository, "commit": head]; + } + return results; +} |