parent
f21f90e061
commit
896007e193
|
@ -531,6 +531,11 @@ public final class CauseData {
|
||||||
data.getTargetProjectUrl());
|
data.getTargetProjectUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, COMMIT_COMMENT {
|
||||||
|
@Override
|
||||||
|
String getShortDescription(CauseData data) {
|
||||||
|
return Messages.GiteeWebHookCause_ShortDescription_Commit_comment(data.getTriggeredByUser());
|
||||||
|
}
|
||||||
}, PIPELINE {
|
}, PIPELINE {
|
||||||
@Override
|
@Override
|
||||||
String getShortDescription(CauseData data) {
|
String getShortDescription(CauseData data) {
|
||||||
|
|
|
@ -58,6 +58,11 @@ public class NoteHook extends WebHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWebHookDescription() {
|
public String getWebHookDescription() {
|
||||||
|
// 兼容commit评论
|
||||||
|
if (pullRequest == null) {
|
||||||
|
return getHookName() + " commit sha = " + comment.getCommitId();
|
||||||
|
}
|
||||||
|
|
||||||
return getHookName() + " iid = " + pullRequest.getNumber() + " merge commit sha = " + pullRequest.getMergeCommitSha();
|
return getHookName() + " iid = " + pullRequest.getNumber() + " merge commit sha = " + pullRequest.getMergeCommitSha();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ public class NoteObjectAttributes {
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
private Date updatedAt;
|
private Date updatedAt;
|
||||||
private String htmlUrl;
|
private String htmlUrl;
|
||||||
|
private String commitId;
|
||||||
|
private User user;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -77,6 +79,22 @@ public class NoteObjectAttributes {
|
||||||
this.htmlUrl = htmlUrl;
|
this.htmlUrl = htmlUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCommitId() {
|
||||||
|
return commitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommitId(String commitId) {
|
||||||
|
this.commitId = commitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
|
@ -94,6 +112,8 @@ public class NoteObjectAttributes {
|
||||||
.append(createdAt, that.createdAt)
|
.append(createdAt, that.createdAt)
|
||||||
.append(updatedAt, that.updatedAt)
|
.append(updatedAt, that.updatedAt)
|
||||||
.append(htmlUrl, that.htmlUrl)
|
.append(htmlUrl, that.htmlUrl)
|
||||||
|
.append(commitId, that.commitId)
|
||||||
|
.append(user, that.user)
|
||||||
.isEquals();
|
.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +127,8 @@ public class NoteObjectAttributes {
|
||||||
.append(createdAt)
|
.append(createdAt)
|
||||||
.append(updatedAt)
|
.append(updatedAt)
|
||||||
.append(htmlUrl)
|
.append(htmlUrl)
|
||||||
|
.append(commitId)
|
||||||
|
.append(user)
|
||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +142,8 @@ public class NoteObjectAttributes {
|
||||||
.append("createdAt", createdAt)
|
.append("createdAt", createdAt)
|
||||||
.append("updatedAt", updatedAt)
|
.append("updatedAt", updatedAt)
|
||||||
.append("htmlUrl", htmlUrl)
|
.append("htmlUrl", htmlUrl)
|
||||||
|
.append("commitId", commitId)
|
||||||
|
.append("user", user)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,35 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CauseData retrieveCauseData(NoteHook hook) {
|
protected CauseData retrieveCauseData(NoteHook hook) {
|
||||||
|
// 兼容来自commit的评论
|
||||||
|
if (hook.getPullRequest() == null) {
|
||||||
|
return causeData()
|
||||||
|
.withActionType(CauseData.ActionType.COMMIT_COMMENT)
|
||||||
|
.withUserName(hook.getComment().getUser().getUsername())
|
||||||
|
.withUserEmail(hook.getComment().getUser().getEmail())
|
||||||
|
.withPullRequestTitle("")
|
||||||
|
.withBranch("")
|
||||||
|
.withSourceBranch("")
|
||||||
|
.withSourceProjectId(hook.getProject().getId())
|
||||||
|
.withSourceRepoHomepage(hook.getProject().getHomepage())
|
||||||
|
.withSourceRepoName(hook.getProject().getName())
|
||||||
|
.withSourceNamespace(hook.getProject().getNamespace())
|
||||||
|
.withSourceRepoUrl(hook.getProject().getUrl())
|
||||||
|
.withSourceRepoSshUrl(hook.getProject().getSshUrl())
|
||||||
|
.withSourceRepoHttpUrl(hook.getProject().getGitHttpUrl())
|
||||||
|
.withTargetBranch("")
|
||||||
|
.withTargetProjectId(hook.getProject().getId())
|
||||||
|
.withTargetRepoName(hook.getProject().getName())
|
||||||
|
.withTargetNamespace(hook.getProject().getNamespace())
|
||||||
|
.withTargetRepoSshUrl(hook.getProject().getSshUrl())
|
||||||
|
.withTargetRepoHttpUrl(hook.getProject().getGitHttpUrl())
|
||||||
|
.withTriggeredByUser(hook.getComment().getUser().getName())
|
||||||
|
.withTriggerPhrase(hook.getComment().getBody())
|
||||||
|
.withSha(hook.getComment().getCommitId())
|
||||||
|
.withPathWithNamespace(hook.getProject().getPathWithNamespace())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
return causeData()
|
return causeData()
|
||||||
.withActionType(CauseData.ActionType.NOTE)
|
.withActionType(CauseData.ActionType.NOTE)
|
||||||
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
.withSourceProjectId(hook.getPullRequest().getSourceProjectId())
|
||||||
|
@ -188,9 +217,15 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
||||||
if (hook.getPullRequest() != null
|
if (hook.getPullRequest() != null
|
||||||
&& hook.getPullRequest().getMergeReferenceName() != null) {
|
&& hook.getPullRequest().getMergeReferenceName() != null) {
|
||||||
return hook.getPullRequest().getMergeReferenceName();
|
return hook.getPullRequest().getMergeReferenceName();
|
||||||
} else {
|
|
||||||
throw new NoRevisionToBuildException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 兼容来自commit的评论
|
||||||
|
if (hook.getComment() != null
|
||||||
|
&& StringUtils.isNotBlank(hook.getComment().getCommitId())) {
|
||||||
|
return hook.getComment().getCommitId();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NoRevisionToBuildException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidTrigger(NoteHook hook) {
|
private boolean isValidTrigger(NoteHook hook) {
|
||||||
|
|
|
@ -4,5 +4,6 @@ GiteeWebHookCause.ShortDescription.PullRequestHook_html=Triggered by <a href="{3
|
||||||
GiteeWebHookCause.ShortDescription.PullRequestHook_plain=Triggered by Gitee Pull Request #{0}: {1} => {2}
|
GiteeWebHookCause.ShortDescription.PullRequestHook_plain=Triggered by Gitee Pull Request #{0}: {1} => {2}
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_html=Triggered by {0} <a href="{4}/pulls/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3}
|
GiteeWebHookCause.ShortDescription.NoteHook_html=Triggered by {0} <a href="{4}/pulls/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3}
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_plain=Triggered by {0} Gitee Pull Request #{1}: {2} => {3}
|
GiteeWebHookCause.ShortDescription.NoteHook_plain=Triggered by {0} Gitee Pull Request #{1}: {2} => {3}
|
||||||
|
GiteeWebHookCause.ShortDescription.Commit_comment=Started by Gitee comment by {0}
|
||||||
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=Started by Gitee Pipeline event
|
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=Started by Gitee Pipeline event
|
||||||
GiteeWebHookCause.ShortDescription.PipelineHook=Started by Gitee Pipeline event {0}
|
GiteeWebHookCause.ShortDescription.PipelineHook=Started by Gitee Pipeline event {0}
|
||||||
|
|
|
@ -4,5 +4,6 @@ GiteeWebHookCause.ShortDescription.PullRequestHook_html=\u7531 <a href="{3}/pull
|
||||||
GiteeWebHookCause.ShortDescription.PullRequestHook_plain=\u7531 Gitee Pull Request #{0}: {1} => {2} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.PullRequestHook_plain=\u7531 Gitee Pull Request #{0}: {1} => {2} \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_html=\u7531 {0} <a href="{4}/pulls/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.NoteHook_html=\u7531 {0} <a href="{4}/pulls/{1}" target="_blank">Gitee Pull Request #{1}</a>: {2} => {3} \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.NoteHook_plain=\u7531 {0} Gitee Pull Request #{1}: {2} => {3} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.NoteHook_plain=\u7531 {0} Gitee Pull Request #{1}: {2} => {3} \u89E6\u53D1
|
||||||
|
GiteeWebHookCause.ShortDescription.Commit_comment=Gitee \u7528\u6237 {0} \u8BC4\u8BBA\u63D0\u4EA4\u89E6\u53D1\u6784\u5EFA
|
||||||
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=\u7531 Gitee Pipeline \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.PipelineHook_noStatus=\u7531 Gitee Pipeline \u89E6\u53D1
|
||||||
GiteeWebHookCause.ShortDescription.PipelineHook=\u7531 Gitee Pipeline {0} \u89E6\u53D1
|
GiteeWebHookCause.ShortDescription.PipelineHook=\u7531 Gitee Pipeline {0} \u89E6\u53D1
|
||||||
|
|
Loading…
Reference in New Issue