28 lines
1.2 KiB
Java
28 lines
1.2 KiB
Java
import java.nio.file.*;
|
|
import java.util.*;
|
|
|
|
public class fix_urls {
|
|
public static void main(String[] args) throws Exception {
|
|
// Fix both template and data files
|
|
String[] files = {"data/project_paths.txt", "src/main/resources/templates/project_paths.txt"};
|
|
for (String file : files) {
|
|
Path p = Paths.get(file);
|
|
List<String> lines = Files.readAllLines(p, java.nio.charset.StandardCharsets.UTF_8);
|
|
int fixed = 0;
|
|
for (int i = 0; i < lines.size(); i++) {
|
|
String l = lines.get(i);
|
|
if (l.contains("=") && l.endsWith("cf/")) {
|
|
int eq = l.lastIndexOf('=');
|
|
String path = l.substring(0, eq).trim();
|
|
String url = l.substring(eq + 1).trim();
|
|
String proj = path.substring(path.lastIndexOf('/') + 1);
|
|
lines.set(i, path + "=" + url + proj + ".git");
|
|
fixed++;
|
|
}
|
|
}
|
|
Files.write(p, lines, java.nio.charset.StandardCharsets.UTF_8);
|
|
System.out.println(file + ": fixed " + fixed + " lines, total " + lines.size());
|
|
}
|
|
}
|
|
}
|