Skip to content

Commit

Permalink
feat: 监听非当前仓库hook事件 TencentBlueKing#6432
Browse files Browse the repository at this point in the history
  • Loading branch information
yongyiduan committed Mar 28, 2022
1 parent 1708691 commit 7e7eeef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,9 @@ data class GitChangeFileInfo(

fun GitEvent.isDeleteEvent() = (this is GitPushEvent && this.isDeleteBranch()) ||
(this is GitTagPushEvent && this.isDeleteTag())

fun GitEvent.isMrMergeEvent() = this is GitMergeRequestEvent && this.isMrMergeEvent()

fun GitEvent.isMrForkEvent() = this is GitMergeRequestEvent && this.isMrForkEvent()

fun GitEvent.isMrForkNotMergeEvent() = !this.isMrMergeEvent() && this.isMrForkEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ package com.tencent.devops.common.webhook.pojo.code.git

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import com.tencent.devops.common.webhook.enums.code.tgit.TGitMergeActionKind

@Suppress("ALL")
data class GitMergeRequestEvent(
Expand Down Expand Up @@ -69,3 +70,8 @@ data class GitMRAttributes(
@JsonProperty("merge_commit_sha")
val mergeCommitSha: String? = null
)

fun GitMergeRequestEvent.isMrMergeEvent() = this.object_attributes.action == TGitMergeActionKind.MERGE.value

fun GitMergeRequestEvent.isMrForkEvent() =
this.object_attributes.target_project_id != this.object_attributes.source_project_id

0 comments on commit 7e7eeef

Please sign in to comment.