Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comment author to CauseData for Note events #1372

Merged
merged 4 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public final class CauseData {
private final String createdAt;
private final String finishedAt;
private final String buildDuration;
private final String commentAuthor;

@GeneratePojoBuilder(withFactoryMethod = "*")
CauseData(ActionType actionType, Integer sourceProjectId, Integer targetProjectId, String branch, String sourceBranch, String userName,
Expand All @@ -68,7 +69,7 @@ public final class CauseData {
Integer mergeRequestIid, Integer mergeRequestTargetProjectId, String targetBranch, String targetRepoName, String targetNamespace, String targetRepoSshUrl,
String targetRepoHttpUrl, String triggeredByUser, String before, String after, String lastCommit, String targetProjectUrl,
String triggerPhrase, String mergeRequestState, String mergedByUser, String mergeRequestAssignee, String ref, String isTag,
String sha, String beforeSha, String status, String stages, String createdAt, String finishedAt, String buildDuration) {
String sha, String beforeSha, String status, String stages, String createdAt, String finishedAt, String buildDuration, String commentAuthor) {
this.actionType = Objects.requireNonNull(actionType, "actionType must not be null.");
this.sourceProjectId = Objects.requireNonNull(sourceProjectId, "sourceProjectId must not be null.");
this.targetProjectId = Objects.requireNonNull(targetProjectId, "targetProjectId must not be null.");
Expand Down Expand Up @@ -111,6 +112,7 @@ public final class CauseData {
this.createdAt = createdAt;
this.finishedAt = finishedAt;
this.buildDuration = buildDuration;
this.commentAuthor = commentAuthor;
}

@Exported
Expand Down Expand Up @@ -144,6 +146,7 @@ public Map<String, String> getBuildVariables() {
variables.put("gitlabTargetRepoHttpUrl", targetRepoHttpUrl);
variables.put("gitlabBefore", before);
variables.put("gitlabAfter", after);
variables.putIfNotNull("gitlabCommentAuthor", commentAuthor);
variables.put("ref", ref);
variables.put("beforeSha", beforeSha);
variables.put("isTag", isTag);
Expand Down Expand Up @@ -329,6 +332,9 @@ public String getTargetProjectUrl() {
@Exported
public String getBuildDuration() { return buildDuration; }

@Exported
public String getCommentAuthor() { return commentAuthor; }


String getShortDescription() {
return actionType.getShortDescription(this);
Expand Down Expand Up @@ -410,6 +416,7 @@ public boolean equals(Object o) {
.append(createdAt, causeData.getCreatedAt())
.append(finishedAt, causeData.getFinishedAt())
.append(buildDuration, causeData.getBuildDuration())
.append(commentAuthor, causeData.getCommentAuthor())
.isEquals();
}

Expand Down Expand Up @@ -457,6 +464,7 @@ public int hashCode() {
.append(createdAt)
.append(finishedAt)
.append(buildDuration)
.append(commentAuthor)
.toHashCode();
}

Expand Down Expand Up @@ -504,6 +512,7 @@ public String toString() {
.append("createdAt", createdAt)
.append("finishedAt", finishedAt)
.append("duration", buildDuration)
.append("commentAuthor", commentAuthor)
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected CauseData retrieveCauseData(NoteHook hook) {
.withLastCommit(hook.getMergeRequest().getLastCommit().getId())
.withTargetProjectUrl(hook.getMergeRequest().getTarget().getWebUrl())
.withTriggerPhrase(hook.getObjectAttributes().getNote())
.withCommentAuthor(hook.getUser() == null ? null : hook.getUser().getUsername())
.build();
}

Expand Down