diff --git a/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/SourceActions.java b/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/SourceActions.java index 31d33fa..e677d35 100644 --- a/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/SourceActions.java +++ b/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/SourceActions.java @@ -24,6 +24,7 @@ import jenkins.scm.api.metadata.ObjectMetadataAction; import jenkins.scm.api.metadata.PrimaryInstanceMetadataAction; import jenkins.scm.api.mixin.ChangeRequestSCMHead; +import jenkins.scm.api.metadata.ContributorMetadataAction; import jenkins.scm.api.mixin.TagSCMHead; import org.apache.commons.lang.StringUtils; @@ -74,6 +75,8 @@ private List retrieve(@Nonnull GitLabSCMHead head, @CheckForNull SCMHead if (head instanceof ChangeRequestSCMHead) { GitLabMergeRequest mr = retrieveMergeRequest((ChangeRequestSCMHead) head, listener); linkAction = GitLabLinkAction.toMergeRequest(mr.getWebUrl()); + actions.add(createAuthorMetadataAction(mr)); + actions.add(createHeadMetadataAction(((GitLabSCMMergeRequestHead) head).getDescription(), ((GitLabSCMMergeRequestHead) head).getSource(), null, linkAction.getUrlName())); if (acceptMergeRequest(head)) { boolean removeSourceBranch = mr.getRemoveSourceBranch() || removeSourceBranch(head); actions.add(new GitLabSCMAcceptMergeRequestAction(mr, mr.getIid(), source.getSourceSettings().getMergeCommitMessage(), removeSourceBranch)); @@ -121,6 +124,10 @@ private List retrieve(@Nonnull SCMRevisionImpl revision, @CheckForNull S return actions; } + private Action createAuthorMetadataAction(GitLabMergeRequest mr) { + return new ContributorMetadataAction(mr.getAuthor().getName(), mr.getAuthor().getUsername(), mr.getAuthor().getEmail()); + } + private Action createHeadMetadataAction(String name, GitLabSCMHead head, String hash, String url) { return new GitLabSCMHeadMetadataAction(name, head.getProjectId(), head.getName(), hash, url); } diff --git a/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMHead.java b/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMHead.java index f30ab62..4d5bbd8 100644 --- a/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMHead.java +++ b/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMHead.java @@ -25,8 +25,8 @@ public static GitLabSCMMergeRequestHead createMergeRequest(int id, String name, return createMergeRequest(id, name, iid, source, target, false); } - public static GitLabSCMMergeRequestHead createMergeRequest(int id, String name, int iid, GitLabSCMHead source, GitLabSCMBranchHead target, boolean mergeable) { - return new GitLabSCMMergeRequestHead(id, "!" + iid + " - " + name, source, target, mergeable); + public static GitLabSCMMergeRequestHead createMergeRequest(int id, String description, int iid, GitLabSCMHead source, GitLabSCMBranchHead target, boolean mergeable) { + return new GitLabSCMMergeRequestHead(id, "MR-" + iid, description, source, target, mergeable); } public static GitLabSCMBranchHead createBranch(int projectId, String name, String hash, boolean hasMergeRequest) { diff --git a/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMMergeRequestHead.java b/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMMergeRequestHead.java index 81a323e..21b397e 100644 --- a/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMMergeRequestHead.java +++ b/src/main/java/argelbargel/jenkins/plugins/gitlab_branch_source/heads/GitLabSCMMergeRequestHead.java @@ -32,26 +32,32 @@ public final class GitLabSCMMergeRequestHead extends GitLabSCMHeadImpl implements ChangeRequestSCMHead { private final int id; private final String title; + private final String description; private final GitLabSCMHead sourceBranch; private final GitLabSCMBranchHead targetBranch; private final boolean mergeable; private final boolean merge; - GitLabSCMMergeRequestHead(int id, String title, GitLabSCMHead source, GitLabSCMBranchHead target, boolean mergeable) { - this(id, title, source, target, mergeable, false); + GitLabSCMMergeRequestHead(int id, String title, String description, GitLabSCMHead source, GitLabSCMBranchHead target, boolean mergeable) { + this(id, title, description, source, target, mergeable, false); } - private GitLabSCMMergeRequestHead(int id, String title, GitLabSCMHead source, GitLabSCMBranchHead target, boolean mergeable, boolean merge) { - super(source.getProjectId(), title + (merge ? " (merge)" : ""), source.getRevision().getHash(), Messages.GitLabSCMMergeRequest_Pronoun(), MERGE_REQUESTS); + private GitLabSCMMergeRequestHead(int id, String title, String description, GitLabSCMHead source, GitLabSCMBranchHead target, boolean mergeable, boolean merge) { + super(source.getProjectId(), title + (merge ? "-merged" : ""), source.getRevision().getHash(), Messages.GitLabSCMMergeRequest_Pronoun(), MERGE_REQUESTS); this.id = id; this.title = title; + this.description = description; this.sourceBranch = source; this.targetBranch = target; this.mergeable = mergeable; this.merge = merge; } + public String getDescription() { + return description; + } + @Nonnull @Override public String getId() { @@ -65,7 +71,7 @@ public GitLabSCMHead getTarget() { } public GitLabSCMMergeRequestHead merged() { - return new GitLabSCMMergeRequestHead(id, title, sourceBranch, targetBranch, mergeable, true); + return new GitLabSCMMergeRequestHead(id, title, description, sourceBranch, targetBranch, mergeable, true); } public GitLabSCMHead getSource() {