From d8cf50e57585f94be5a4196bd6ab7f4db2a593d7 Mon Sep 17 00:00:00 2001
From: Yogya Tulip Gamage <47789154+yogyagamage@users.noreply.github.com>
Date: Thu, 27 Jul 2023 11:32:32 +0200
Subject: [PATCH] Handle versions without patch version and update charset to
read log files (#106)
* Update the parseVersionUpdateType method to handle versions without patch
* Avoid MalformedInput exception by changing the charset
---
README.md | 2 +-
src/main/java/miner/BreakingUpdate.java | 20 ++++++++++++--------
src/main/java/reproducer/ResultManager.java | 2 +-
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index d9507364353f..67693c7bc9e7 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,7 @@ java -jar target/BreakingUpdateReproducer.jar --help
```
## Stats
-As of Jul 21 2023:
+As of Jul 27 2023:
* The benchmark consists of 2 reproducible breaking updates.
- Of these breaking updates, 0 (0.00%) fail compilation with the updated dependency.
- 0 (0.00%) fail tests with the updated dependency.
diff --git a/src/main/java/miner/BreakingUpdate.java b/src/main/java/miner/BreakingUpdate.java
index 8b8136b946e4..453a6337f5c6 100644
--- a/src/main/java/miner/BreakingUpdate.java
+++ b/src/main/java/miner/BreakingUpdate.java
@@ -31,6 +31,7 @@ public class BreakingUpdate {
private static final Pattern SCOPE =
Pattern.compile("^\\s*(.*)\\s*$");
private static final Pattern SEM_VER = Pattern.compile("^\\d+\\.\\d+\\.\\d+$");
+ private static final Pattern SEM_VER_WITHOUT_PATCH = Pattern.compile("^\\d+\\.\\d+$");
public final String url;
public final String project;
public final String breakingCommit;
@@ -88,7 +89,7 @@ private String parsePRAuthorType(GHPullRequest pr, String defaultResult) {
String userLogin = user.getLogin().toLowerCase();
// Sometimes, the user type does not get equal to BOT even if the user is actually a bot. Therefore, we add
// additional checks.
- return user.getType().equals("Bot") || userLogin.contains("dependabot") || userLogin.contains("renovate")?
+ return user.getType().equals("Bot") || userLogin.contains("dependabot") || userLogin.contains("renovate") ?
"bot" : "human";
} catch (IOException e) {
log.error("prAuthorType could not be parsed", e);
@@ -111,7 +112,7 @@ private String parsePreCommitAuthorType(GHRepository repository, String commitSH
String userLogin = user.getLogin().toLowerCase();
// Sometimes, the user type does not get equal to BOT even if the user is actually a bot. Therefore, we add
// additional checks.
- return user.getType().equals("Bot") || userLogin.contains("dependabot") || userLogin.contains("renovate")?
+ return user.getType().equals("Bot") || userLogin.contains("dependabot") || userLogin.contains("renovate") ?
"bot" : "human";
} catch (IOException e) {
log.error("preCommitAuthorType could not be parsed", e);
@@ -179,11 +180,11 @@ public UpdatedDependency(GHPullRequest pr) {
*/
@JsonCreator
UpdatedDependency(@JsonProperty("dependencyGroupID") String dependencyGroupID,
- @JsonProperty("dependencyArtifactID") String dependencyArtifactID,
- @JsonProperty("previousVersion") String previousVersion,
- @JsonProperty("newVersion") String newVersion,
- @JsonProperty("dependencyScope") String dependencyScope,
- @JsonProperty("versionUpdateType") String versionUpdateType) {
+ @JsonProperty("dependencyArtifactID") String dependencyArtifactID,
+ @JsonProperty("previousVersion") String previousVersion,
+ @JsonProperty("newVersion") String newVersion,
+ @JsonProperty("dependencyScope") String dependencyScope,
+ @JsonProperty("versionUpdateType") String versionUpdateType) {
this.dependencyGroupID = dependencyGroupID;
this.dependencyArtifactID = dependencyArtifactID;
this.previousVersion = previousVersion;
@@ -221,7 +222,10 @@ private String parsePatch(GHPullRequest pr, Pattern searchTerm, String defaultRe
* "other" otherwise.
*/
private String parseVersionUpdateType(String previousVersion, String newVersion) {
- if (!SEM_VER.matcher(previousVersion).matches() || !SEM_VER.matcher(newVersion).matches())
+
+
+ if (!(SEM_VER.matcher(previousVersion).matches() || SEM_VER_WITHOUT_PATCH.matcher(previousVersion).matches())
+ || !(SEM_VER.matcher(newVersion).matches() || SEM_VER_WITHOUT_PATCH.matcher(newVersion).matches()))
return "other";
List originalVersionNumbers = Arrays.stream(previousVersion.split("\\."))
diff --git a/src/main/java/reproducer/ResultManager.java b/src/main/java/reproducer/ResultManager.java
index 14bd44f01912..d0ab998118fb 100644
--- a/src/main/java/reproducer/ResultManager.java
+++ b/src/main/java/reproducer/ResultManager.java
@@ -323,7 +323,7 @@ private UpdatedFileType extractDependencies(BreakingUpdate bu, String postContai
*/
private FailureCategory getFailureCategory(Path path) {
try {
- String logContent = Files.readString(path);
+ String logContent = Files.readString(path, StandardCharsets.ISO_8859_1);
for (Map.Entry entry : FAILURE_PATTERNS.entrySet()) {
Pattern pattern = entry.getKey();
Matcher matcher = pattern.matcher(logContent);