Skip to content

Commit

Permalink
feat: Add pullRequestUrl return in GithubApiUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
npole0103 committed Oct 17, 2022
1 parent 286e826 commit 841164c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/kr/markdown/alreadyme/utils/GithubApiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static String gitFork(String githubUrl, String token) {
return null;
}

public static void gitPullRequest(String githubUrl, String token, String branchName) {
public static String gitPullRequest(String githubUrl, String token, String branchName, String masterBranchName) {
try {
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("https://api.github.com/repos"+ exportGitRepoPath(githubUrl)+"/pulls");
Expand All @@ -47,15 +47,22 @@ public static void gitPullRequest(String githubUrl, String token, String branchN
node.put("title", "Add README.md by ALREADYME-BOT");
node.put("body", "This text was created by ALREADYME-BOT\nhttps://github.com/ALREADYME-BOT");
node.put("head", "ALREADYME-BOT:" + branchName);
node.put("base", branchName);
node.put("base", masterBranchName);

httpPost.setEntity(new StringEntity(node.toString(), "UTF-8"));

httpClient.execute(httpPost);
HttpResponse httpResponse = httpClient.execute(httpPost);
String jsonStr = EntityUtils.toString(httpResponse.getEntity());

ObjectMapper resMapper = new ObjectMapper();
JsonNode resNode = resMapper.readTree(jsonStr);
System.out.println(jsonStr);
return resNode.get("html_url").asText();

} catch (Exception e) {
e.printStackTrace();
}
return null;
}

public static void gitDeleteRemoteRepository(String githubUrl, String token) {
Expand Down

0 comments on commit 841164c

Please sign in to comment.