Skip to content

Commit 835832b

Browse files
authored
ref 브랜치와 default 브랜치가 같을 경우 리뷰하지 않도록 수정
ref 브랜치와 default 브랜치가 같을 경우 리뷰하지 않도록 수정
2 parents 2f61543 + 06d0c3a commit 835832b

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/main/kotlin/com/project/codereview/core/dto/GithubPayloadDtos.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ data class InstallationPayload(
2020
@JsonIgnoreProperties(ignoreUnknown = true)
2121
data class PullRequestPayload(
2222
val url: String,
23-
val head: PullRequestHeadPayload
23+
val head: PullRequestHeadPayload,
24+
val base: BasePayload
2425
) {
2526
private val _urls = url.removePrefix("https://").split("/")
2627
val owner = _urls[2]
@@ -30,7 +31,18 @@ data class PullRequestPayload(
3031

3132
@JsonIgnoreProperties(ignoreUnknown = true)
3233
data class PullRequestHeadPayload(
33-
val sha: String
34+
val sha: String,
35+
val repo: RepositoryPayload
36+
)
37+
38+
@JsonIgnoreProperties(ignoreUnknown = true)
39+
data class RepositoryPayload(
40+
val default_branch: String
41+
)
42+
43+
@JsonIgnoreProperties(ignoreUnknown = true)
44+
data class BasePayload(
45+
val ref: String
3446
)
3547

3648
val mapper = jacksonObjectMapper()

src/main/kotlin/com/project/codereview/core/service/PullRequestEventEntry.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class PullRequestEventEntry(
2424
return
2525
}
2626

27+
val repositoryDefaultBranch = payload.pull_request.head.repo.default_branch
28+
val targetRefBranch = payload.pull_request.base.ref
29+
if (repositoryDefaultBranch == targetRefBranch) {
30+
logger.debug("Do not review default branch: {}", "$repositoryDefaultBranch to $targetRefBranch")
31+
return
32+
}
33+
2734
val action = GithubActionType.Companion(payload.action)
2835
val pr = payload.pull_request
2936
val diff = githubDiffClient.getPrDiff(pr.owner, pr.repo, pr.prNumber)

0 commit comments

Comments
 (0)