Skip to content
Permalink
Browse files

[JENKINS-43507] Add a test for the GitSCMExtension equals, hashCode a…

…nd toString implementation requirements
  • Loading branch information...
stephenc committed May 3, 2017
1 parent f09e7a2 commit f056b80d23d917d85193ec275e71ad6bcb5fc8d1
@@ -17,11 +17,17 @@
public AuthorInChangelog() {
}

/**
* {@inheritDoc}
*/
@Override
public boolean requiresWorkspaceForPolling() {
return true;
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -33,18 +39,27 @@ public boolean equals(Object o) {
return o instanceof AuthorInChangelog;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return AuthorInChangelog.class.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "AuthorInChangelog{}";
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return "Use commit author in changelog";
@@ -32,22 +32,34 @@ public Integer getTimeout() {
return timeout;
}

/**
* {@inheritDoc}
*/
@Override
public boolean requiresWorkspaceForPolling() {
return false;
}

/**
* {@inheritDoc}
*/
@Override
public void decorateCheckoutCommand(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, CheckoutCommand cmd) throws IOException, InterruptedException, GitException {
cmd.timeout(timeout);
}

/**
* {@inheritDoc}
*/
@Override
@Deprecated
public void decorateCheckoutCommand(GitSCM scm, AbstractBuild<?, ?> build, GitClient git, BuildListener listener, CheckoutCommand cmd) throws IOException, InterruptedException, GitException {
cmd.timeout(timeout);
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -62,11 +74,17 @@ public boolean equals(Object o) {
return timeout != null ? timeout.equals(that.timeout) : that.timeout == null;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return 0;
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "CheckoutOption{" +
@@ -77,6 +95,9 @@ public String toString() {
@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return "Advanced checkout behaviours";
@@ -1,21 +1,16 @@
package hudson.plugins.git.extensions.impl;

import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.TaskListener;
import hudson.plugins.git.GitException;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;

import org.jenkinsci.plugins.gitclient.CloneCommand;
import java.io.IOException;
import org.jenkinsci.plugins.gitclient.FetchCommand;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;

/**
* git-clean before the checkout.
*
@@ -26,6 +21,9 @@
public CleanBeforeCheckout() {
}

/**
* {@inheritDoc}
*/
@Override
public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listener, FetchCommand cmd) throws IOException, InterruptedException, GitException {
listener.getLogger().println("Cleaning workspace");
@@ -36,6 +34,9 @@ public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listene
}
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -47,11 +48,17 @@ public boolean equals(Object o) {
return o instanceof CleanBeforeCheckout;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return CleanBeforeCheckout.class.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "CleanBeforeCheckout{}";
@@ -60,6 +67,9 @@ public String toString() {
@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
/**
* {@inheritDoc}
*/
public String getDisplayName() {
return "Clean before checkout";
}
@@ -7,11 +7,10 @@
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;
import java.io.IOException;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;

/**
* git-clean after the checkout.
*
@@ -22,6 +21,9 @@
public CleanCheckout() {
}

/**
* {@inheritDoc}
*/
@Override
public void onCheckoutCompleted(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener) throws IOException, InterruptedException, GitException {
listener.getLogger().println("Cleaning workspace");
@@ -32,6 +34,9 @@ public void onCheckoutCompleted(GitSCM scm, Run<?, ?> build, GitClient git, Task
}
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -43,18 +48,27 @@ public boolean equals(Object o) {
return o instanceof CleanCheckout;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return CleanCheckout.class.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "CleanCheckout{}";
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return "Clean after checkout";
@@ -8,18 +8,16 @@
import hudson.plugins.git.extensions.GitClientType;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;

import java.io.IOException;
import java.util.List;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
import org.jenkinsci.plugins.gitclient.CloneCommand;
import org.jenkinsci.plugins.gitclient.FetchCommand;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import java.io.IOException;
import java.util.List;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;

/**
* @author Kohsuke Kawaguchi
*/
@@ -111,6 +109,9 @@ public int getDepth() {
return depth;
}

/**
* {@inheritDoc}
*/
@Override
public void decorateCloneCommand(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, CloneCommand cmd) throws IOException, InterruptedException, GitException {
if (shallow) {
@@ -142,11 +143,14 @@ public void decorateCloneCommand(GitSCM scm, Run<?, ?> build, GitClient git, Tas
cmd.reference(build.getEnvironment(listener).expand(reference));
}

/**
* {@inheritDoc}
*/
@Override
public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listener, FetchCommand cmd) throws IOException, InterruptedException, GitException {
cmd.shallow(shallow);
if (shallow && depth > 1) {
cmd.depth(depth);
cmd.depth(depth);
}
cmd.tags(!noTags);
/* cmd.refspecs() not required.
@@ -157,12 +161,18 @@ public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listene
cmd.timeout(timeout);
}

/**
* {@inheritDoc}
*/
@Override
public GitClientType getRequiredClient() {
return GitClientType.GITCLI;
}


/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -192,11 +202,17 @@ public boolean equals(Object o) {
return timeout != null ? timeout.equals(that.timeout) : that.timeout == null;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return CloneOption.class.hashCode();
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "CloneOption{" +
@@ -211,6 +227,9 @@ public String toString() {

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return "Advanced clone behaviours";

0 comments on commit f056b80

Please sign in to comment.
You can’t perform that action at this time.