Skip to content

Commit

Permalink
Handle versions without patch version and update charset to read log …
Browse files Browse the repository at this point in the history
…files (#106)

* Update the parseVersionUpdateType method to handle versions without patch

* Avoid MalformedInput exception by changing the charset
  • Loading branch information
yogyagamage authored Jul 27, 2023
1 parent cc8ec74 commit d8cf50e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/miner/BreakingUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class BreakingUpdate {
private static final Pattern SCOPE =
Pattern.compile("^\\s*<scope>(.*)</scope>\\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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<Integer> originalVersionNumbers = Arrays.stream(previousVersion.split("\\."))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reproducer/ResultManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pattern, FailureCategory> entry : FAILURE_PATTERNS.entrySet()) {
Pattern pattern = entry.getKey();
Matcher matcher = pattern.matcher(logContent);
Expand Down

0 comments on commit d8cf50e

Please sign in to comment.