Skip to content

Commit

Permalink
Revert temporary changes for test file renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Nov 16, 2023
1 parent d1aad26 commit 5bcc8ec
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -222,10 +221,9 @@ protected void before() {
@Override
protected void after() {
super.after();
// TEMP
// if (!isTakeSnapshot()) {
// return;
// }
if (!isTakeSnapshot()) {
return;
}

recordSnapshot(this.apiServer(), "https://api.github.com", false);

Expand Down Expand Up @@ -366,9 +364,6 @@ public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContex
// Can be Array or Map
Object parsedObject = g.fromJson(fileText, Object.class);
String outputFileText = g.toJson(parsedObject);
if (fileText.endsWith("\n")) {
outputFileText += "\n";
}
Files.write(targetFilePath, outputFileText.getBytes());
}
} catch (Exception e) {
Expand Down Expand Up @@ -416,23 +411,13 @@ private Path renameFile(Path filePath, Map<String, String> idToIndex) throws IOE
// Replace GUID strings in file paths with abbreviated GUID to limit file path length for windows
fileName = fileName.replaceAll("(_[a-f0-9]{8})[a-f0-9]{32}([_.])", "$1$2");

// TEMP
// Move all index numbers to the front of the file name for clarity
fileName = fileName.replaceAll("^(.+?)-([0-9]+)\\.", "$2-$1.");
// Short early segments of the file name
// which tend to be "repos_hub4j-test-org_{repository}".
fileName = fileName.replaceAll("^([0-9]+-[a-zA-Z])[^_]+_([a-zA-Z])[^_]+_([a-zA-Z])[^_]+_", "$1_$2_$3_");
fileName = fileName.replaceAll("^([0-9]+-[a-zA-Z])[^_]+_([a-zA-Z])[^_]+_", "$1_$2_");

// If the file name is still longer than 60 characters, truncate it
fileName = fileName.replaceAll("^([^.]{60})[^.]+\\.", "$1.");

String renamedFilePathString = Paths.get(filePath.getParent().toString(), fileName).toString();
if (renamedFilePathString != filePath.toString()) {
targetPath = new File(renamedFilePathString).toPath();
// Files.move(filePath, targetPath);
// TEMP
Files.move(filePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
Files.move(filePath, targetPath);
}
return targetPath;
}
Expand Down

0 comments on commit 5bcc8ec

Please sign in to comment.