Skip to content

Commit

Permalink
Generate only neccessary path to md files from labels
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless committed Sep 6, 2024
1 parent 4be8db3 commit 6ca05c5
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,14 @@ private static void updateLabelFile(String labelFilePath, String updatedData) {
public static void updateLinksInLabels(String docsPath) {
String labelsPath = docsPath + LABELS;

int numberOfDirs = docsPath.length() - docsPath.replace("/", "").length();
String mdFilesPath = "../".repeat(numberOfDirs);

if (Files.exists(new File(labelsPath).toPath())) {
for (Map.Entry<String, Map<String, String>> entry : MdGenerator.labelsMap.entrySet()) {
String labelsFile = labelsPath + "/" + entry.getKey() + ".md";

if (Files.exists(new File(labelsFile).toPath())) {
StringBuilder newText = new StringBuilder("**Tests:**");
for (Map.Entry<String, String> item : entry.getValue().entrySet()) {
String data = String.format("[%s](%s%s)", item.getKey(), mdFilesPath, item.getValue());
String data = String.format("[%s](%s%s)", item.getKey(), "../", item.getValue().replace(docsPath, ""));
newText.append("\n- ").append(data);
}

Expand Down

0 comments on commit 6ca05c5

Please sign in to comment.