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

JENKINS-46081: Add MessageExclusion trait #727

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -16,6 +16,7 @@
import org.kohsuke.stapler.QueryParameter;

import java.io.IOException;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

Expand All @@ -40,6 +41,41 @@ public class MessageExclusion extends GitSCMExtension {

public String getExcludedMessage() { return excludedMessage; }

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

MessageExclusion that = (MessageExclusion) o;

return Objects.equals(excludedMessage, that.excludedMessage);
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return Objects.hash(excludedMessage);
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "MessageExclusion{" +
"excludedMessage='" + excludedMessage + '\'' +
'}';
}

@Override
@SuppressFBWarnings(value="NP_BOOLEAN_RETURN_NULL", justification="null used to indicate other extensions should decide")
@CheckForNull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package jenkins.plugins.git.traits;

import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
import hudson.plugins.git.extensions.impl.MessageExclusion;

public class MessageExclusionTrait extends GitSCMExtensionTrait<MessageExclusion> {
/**
* Stapler constructor.
*
* @param extension the {@link MessageExclusion}.
*/
@DataBoundConstructor
public MessageExclusionTrait(MessageExclusion extension) {
super(extension);
}

/**
* Our {@link hudson.model.Descriptor}
*/
@Extension
public static class DescriptorImpl extends GitSCMExtensionTraitDescriptor {
/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return "Message exclusion";
}
}
}
12 changes: 12 additions & 0 deletions src/test/java/jenkins/plugins/git/GitSCMSourceTraitsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import hudson.plugins.git.extensions.impl.CloneOption;
import hudson.plugins.git.extensions.impl.GitLFSPull;
import hudson.plugins.git.extensions.impl.LocalBranch;
import hudson.plugins.git.extensions.impl.MessageExclusion;
import hudson.plugins.git.extensions.impl.PruneStaleBranch;
import hudson.plugins.git.extensions.impl.SparseCheckoutPaths;
import hudson.plugins.git.extensions.impl.SubmoduleOption;
Expand All @@ -28,6 +29,7 @@
import jenkins.plugins.git.traits.GitLFSPullTrait;
import jenkins.plugins.git.traits.IgnoreOnPushNotificationTrait;
import jenkins.plugins.git.traits.LocalBranchTrait;
import jenkins.plugins.git.traits.MessageExclusionTrait;
import jenkins.plugins.git.traits.PruneStaleBranchTrait;
import jenkins.plugins.git.traits.RefSpecsSCMSourceTrait;
import jenkins.plugins.git.traits.RemoteNameSCMSourceTrait;
Expand Down Expand Up @@ -188,6 +190,12 @@ public void pimpped_out() throws Exception {
hasProperty("localBranch", is("**"))
)
),
Matchers.<SCMSourceTrait>instanceOf(CleanAfterCheckoutTrait.class),
Matchers.<SCMSourceTrait>instanceOf(CleanBeforeCheckoutTrait.class),
Matchers.allOf(
instanceOf(MessageExclusionTrait.class),
hasProperty("extension",
hasProperty("excludedMessage", is("does not work"))
MarkEWaite marked this conversation as resolved.
Show resolved Hide resolved
Matchers.<SCMSourceTrait>allOf(
instanceOf(CleanBeforeCheckoutTrait.class),
hasProperty("extension",
Expand Down Expand Up @@ -272,6 +280,10 @@ public void pimpped_out() throws Exception {
hasProperty("name", is("bob")),
hasProperty("email", is("[email protected]"))
),
Matchers.allOf(
instanceOf(MessageExclusion.class),
hasProperty("excludedMessage", is("does not work"))
),
Matchers.<GitSCMExtension>instanceOf(GitLFSPull.class),
Matchers.<GitSCMExtension>instanceOf(PruneStaleBranch.class),
Matchers.<GitSCMExtension>instanceOf(AuthorInChangelog.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ unclassified:
- userIdentity:
email: "[email protected]"
name: "custom user"
- messageExclusion:
excludedMessage: "does not work"
- preBuildMerge:
options:
mergeRemote: "myrepo"
Expand Down