Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.330</version>
<version>2.0-rc.6</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/miner/GitHubMiner.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ private void mineRepo(String repo, Date cutoffDate) throws IOException {

while (pullRequests.hasNext()) {
List<GHPullRequest> nextPage = pullRequests.nextPage();
if (PullRequestFilters.createdBefore(cutoffDate).test(nextPage.get(0))) {
if (PullRequestFilters.createdBefore(cutoffDate.toInstant()).test(nextPage.get(0))) {
log.info("Checked all PRs for " + repo + " created after " + cutoffDate);
break;
}
nextPage.stream()
.takeWhile(PullRequestFilters.createdBefore(cutoffDate).negate())
.takeWhile(PullRequestFilters.createdBefore(cutoffDate.toInstant()).negate())
.filter(PullRequestFilters.changesOnlyDependencyVersionInPomXML)
.filter(PullRequestFilters.breaksBuild)
.map(BreakingUpdate::new)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/miner/PullRequestFilters.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.kohsuke.github.*;

import java.io.IOException;
import java.util.Date;
import java.time.Instant;
import java.util.function.Predicate;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -77,10 +77,10 @@ private PullRequestFilters() { /* Nothing to see here... */ }
* @return a {@link java.util.function.Predicate} over {@link org.kohsuke.github.GHPullRequest}s returning
* true if a PR was created before the given date, false otherwise.
*/
public static Predicate<GHPullRequest> createdBefore(Date cutoffDate) {
public static Predicate<GHPullRequest> createdBefore(Instant cutoffDate) {
return pr -> {
try {
return pr.getCreatedAt().before(cutoffDate);
return pr.getCreatedAt().isBefore(cutoffDate);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/miner/PullRequestFiltersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.io.IOException;
import java.time.Instant;
import java.util.Date;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -32,7 +31,7 @@ void createdBeforeCorrectlyIdentifiesPR() throws IOException {
gitHub.getRepository("iluwatar/java-design-patterns").getPullRequest(1976),
gitHub.getRepository("alibaba/fastjson").getPullRequest(4233)
);
Date cutoffDate = Date.from(Instant.parse("2022-04-01T00:00:00.00Z"));
Instant cutoffDate = Instant.parse("2022-04-01T00:00:00.00Z");
assertEquals(2, prs.stream().filter(PullRequestFilters.createdBefore(cutoffDate)).count());
}
}
Loading