Skip to content

Commit

Permalink
chore: Modify pull-request and commit Message
Browse files Browse the repository at this point in the history
  • Loading branch information
npole0103 committed Oct 25, 2022
1 parent 8c80300 commit 4aee92c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/kr/markdown/alreadyme/service/AppService.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ public PullRequest pullRequest(Request requestDto) throws Exception {
String masterBranchName = git.getRepository().getBranch();
JGitUtil.checkout(git, String.valueOf(requestDto.getId()));
JGitUtil.add(git, ".");
JGitUtil.commit(git, "feat: Add README.md by ALREADYME-BOT", name, email);
JGitUtil.commit(git, "feat: Add README.md by " + id, name, email);
JGitUtil.push(git, id, token);

//GitPullRequest
String pullRequestUrl = GithubApiUtil.gitPullRequest(readmeItem.getGithubOriginalUrl(), token, git.getRepository().getBranch(), masterBranchName);
String pullRequestUrl = GithubApiUtil.gitPullRequest(readmeItem.getGithubOriginalUrl(), token, git.getRepository().getBranch(), masterBranchName, id);

//Delete Local & Remote Repository
JGitUtil.close(git);
Expand Down
9 changes: 4 additions & 5 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 String gitPullRequest(String githubUrl, String token, String branchName, String masterBranchName) {
public static String gitPullRequest(String githubUrl, String token, String branchName, String masterBranchName, String githubId) {
try {
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("https://api.github.com/repos"+ exportGitRepoPath(githubUrl)+"/pulls");
Expand All @@ -44,9 +44,9 @@ public static String gitPullRequest(String githubUrl, String token, String branc

ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.createObjectNode();
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("title", "Add README.md by " + githubId);
node.put("body", "This text was created by " + githubId + "\n" + "https://github.com/" + githubId);
node.put("head", githubId + ":" + branchName);
node.put("base", masterBranchName);

httpPost.setEntity(new StringEntity(node.toString(), "UTF-8"));
Expand All @@ -56,7 +56,6 @@ public static String gitPullRequest(String githubUrl, String token, String branc

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

} catch (Exception e) {
Expand Down

0 comments on commit 4aee92c

Please sign in to comment.