« get me outta code hell

yaml: report unambiguous names for resolving track rereleases - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-15 17:10:29 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-15 17:10:29 -0300
commit886c6d1d30b6d445193a2d3379359b31b1448834 (patch)
treece85fb8f90994f924ef25a6a11d7c1a24bb9e41e
parentf235cf91ab83bc792d6a193d524a20addfeaeb9c (diff)
yaml: report unambiguous names for resolving track rereleases
-rw-r--r--src/data/yaml.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 44bca66b..627f559c 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -1452,10 +1452,20 @@ export function filterReferenceErrors(wikiData) {
                     // It should still be reported since the 'Originally Released As' field
                     // was present.
                     const original = find.track(track.originalReleaseTrackByRef, wikiData.trackData, {mode: 'quiet'});
-                    const shouldBeMessage =
+
+                    // Prefer references by name, but only if it's unambiguous.
+                    const originalByName =
                       (original
+                        ? find.track(original.name, wikiData.trackData, {mode: 'quiet'})
+                        : null);
+
+                    const shouldBeMessage =
+                      (originalByName
+                        ? color.green(original.name)
+                     : original
                         ? color.green('track:' + original.directory)
                         : color.green(track.originalReleaseTrackByRef));
+
                     throw new Error(`Reference ${color.red(trackRef)} is to a rerelease, should be ${shouldBeMessage}`);
                   }