Skip to content

Commit f6ee5f0

Browse files
authored
Merge pull request #63 from vbakke/fix/depends-on-comment
fix: dependsOn comment As current PROD is broken, I override the requirements for reviewers
2 parents ea7ffc0 + a7b2e60 commit f6ee5f0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

yaml-generation/generateDimensions.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
}
111111
}
112112
// Trick emit_yaml() to have uuid plus a comment in a string. Removed in post-processing below.
113-
$dimensionsAggregated[$dimension][$subdimension][$activityName]["dependsOn"][$index] = "{ $dependsOnUuid # $dependsOnName }";
113+
$dimensionsAggregated[$dimension][$subdimension][$activityName]["dependsOn"][$index] = "{!$dependsOnUuid!}";
114114

115115

116116
// Build dependency graph
@@ -156,17 +156,17 @@
156156
}
157157

158158

159-
// Store generated data
159+
// Post-process to add activity name as comment for `dependsOn`
160160
$dimensionsString = yaml_emit($dimensionsAggregated);
161+
preg_match_all('/\{!([0-9a-z-]{30,})!\}/', $dimensionsString, $matches);
162+
$uuids = array_unique($matches[1]);
163+
foreach ($uuids as $uuid) {
164+
$name = getActivityNameByUuid($uuid, $dimensionsAggregated);
165+
// echo "Adding dependsOn-comment for $uuid: $name\n";
166+
$dimensionsString = str_replace("'{!$uuid!}'", "$uuid # $name", $dimensionsString);
167+
}
161168

162-
// Post-process to convert quoted UUID comments to inline comments
163-
// Pattern: `- '{ uuid #comment }'` becomes: `- uuid #comment`
164-
$dimensionsString = preg_replace(
165-
"/^(\s+- )'{\s*([0-9a-f-]+)\s+(#[^'}]*)\s*}'$/m",
166-
"$1$2 $3",
167-
$dimensionsString
168-
);
169-
169+
// Store generated data
170170
$targetGeneratedFile = getcwd() . "/src/assets/YAML/generated/generated.yaml";
171171
echo "\nStoring to $targetGeneratedFile\n";
172172
file_put_contents($targetGeneratedFile, $dimensionsString);

0 commit comments

Comments
 (0)