From 42a6e42605fa01b28c1caf8b9103b2fb834567d9 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 4 Sep 2024 19:22:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=A1=B0=ED=9A=8C=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EA=B0=80=20=EC=A0=81=EC=A0=88=ED=95=9C=20=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?=EB=B0=9B=EB=8F=84=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/application/StudentStudyHistoryService.java | 9 +-------- .../gdsc/infra/github/client/GithubClient.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index 17da03cf1..d631f3779 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -1,6 +1,5 @@ package com.gdschongik.gdsc.domain.study.application; -import static com.gdschongik.gdsc.global.common.constant.GithubConstant.*; import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import com.gdschongik.gdsc.domain.member.domain.Member; @@ -56,8 +55,7 @@ public void updateRepository(Long studyId, RepositoryUpdateRequest request) thro boolean isAnyAssignmentSubmitted = assignmentHistoryRepository.existsSubmittedAssignmentByMemberAndStudy(currentMember, study); - String ownerRepo = getOwnerRepo(request.repositoryLink()); - GHRepository repository = githubClient.getRepository(ownerRepo); + GHRepository repository = githubClient.getRepository(request.repositoryLink()); // TODO: GHRepository 등을 wrapper로 감싸서 테스트 가능하도록 변경 studyHistoryValidator.validateUpdateRepository( isAnyAssignmentSubmitted, String.valueOf(repository.getOwner().getId()), currentMember.getOauthId()); @@ -71,11 +69,6 @@ public void updateRepository(Long studyId, RepositoryUpdateRequest request) thro request.repositoryLink()); } - private String getOwnerRepo(String repositoryLink) { - int startIndex = repositoryLink.indexOf(GITHUB_DOMAIN) + GITHUB_DOMAIN.length(); - return repositoryLink.substring(startIndex); - } - @Transactional(readOnly = true) public List getAllAssignmentHistories(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); diff --git a/src/main/java/com/gdschongik/gdsc/infra/github/client/GithubClient.java b/src/main/java/com/gdschongik/gdsc/infra/github/client/GithubClient.java index b7eb73fb5..9b5ec8546 100644 --- a/src/main/java/com/gdschongik/gdsc/infra/github/client/GithubClient.java +++ b/src/main/java/com/gdschongik/gdsc/infra/github/client/GithubClient.java @@ -30,8 +30,9 @@ public class GithubClient { private final GitHub github; private final GitHubConnector gitHubConnector = GitHubConnector.DEFAULT; - public GHRepository getRepository(String ownerRepo) { + public GHRepository getRepository(String repo) { try { + String ownerRepo = getOwnerRepo(repo); return github.getRepository(ownerRepo); } catch (IOException e) { throw new CustomException(GITHUB_REPOSITORY_NOT_FOUND); @@ -59,7 +60,8 @@ public AssignmentSubmissionFetcher getLatestAssignmentSubmissionFetcher(String r } private AssignmentSubmission getLatestAssignmentSubmission(String repo, int week) { - GHRepository ghRepository = getRepository(repo); + String ownerRepo = getOwnerRepo(repo); + GHRepository ghRepository = getRepository(ownerRepo); String assignmentPath = GITHUB_ASSIGNMENT_PATH.formatted(week); // GHContent#getSize() 의 경우 한글 문자열을 byte 단위로 계산하기 때문에, 직접 content를 읽어서 길이를 계산 @@ -107,4 +109,9 @@ private LocalDateTime getCommitDate(GHCommit ghLatestCommit) { throw new CustomException(GITHUB_COMMIT_DATE_FETCH_FAILED); } } + + private String getOwnerRepo(String repositoryLink) { + int startIndex = repositoryLink.indexOf(GITHUB_DOMAIN) + GITHUB_DOMAIN.length(); + return repositoryLink.substring(startIndex); + } }