Skip to content

Commit

Permalink
Start looking into some auto merge / rebase logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-openai committed Sep 13, 2024
1 parent c0359ea commit c3cf611
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ public List<GHIssueComment> getPRComments(String repository, int prNumber) {
}
}

public void listPR(String repository) {
try {
GitHub gc = getGithubClient(repository);
gc.getRepository(repository);
} catch (IOException | NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new RuntimeException(e);
}
}

public GHPullRequest createPR(
String repository,
String title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHPullRequest;
import org.kohsuke.github.GHPullRequestQueryBuilder;
import org.kohsuke.github.GitHub;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -18,13 +22,40 @@
"l10n.githubClients.client-1.key=testKey1",
"l10n.githubClients.client-2.owner=testOwner2",
"l10n.githubClients.client-2.appId=testAppId2",
"l10n.githubClients.client-2.key=testKey2",
"l10n.githubClients.client-2.key=testKey2"
})
@EnableConfigurationProperties
public class GithubClientsTest {

@Autowired GithubClients githubClients;

@Test
public void test() throws Exception {
GithubClient openai = githubClients.getClient("openai");
GitHub openai2 = openai.createGithubClient("openai");

GHPullRequestQueryBuilder ghPullRequestQueryBuilder =
openai2.getRepository("openai/openai").queryPullRequests();

var prPrefix = "l10n-update-";

var openL10NUpdatePRs =
ghPullRequestQueryBuilder.state(GHIssueState.OPEN).list().toList().stream()
.filter(ghPullRequest -> ghPullRequest.getHead().getRef().startsWith("l10n-update-"))
.toList();

// GHCommitStatus latestStatus = ghPullRequest.getHead().getCommit().getStatus();
// GHCommitState state = latestStatus.getState(); // Get the state of the last commit

for (GHPullRequest ghPullRequest : openL10NUpdatePRs) {
System.out.format(
"%s - %s [%s]%n",
ghPullRequest.getHead().getCommit(),
ghPullRequest.getHtmlUrl(),
ghPullRequest.getHead().getCommit().getLastStatus().getState());
}
}

@Test
public void testClientCreation() {
GithubClient githubClient1 = githubClients.getClient("testOwner1");
Expand Down

0 comments on commit c3cf611

Please sign in to comment.