Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #494 from stephenc/jenkins-43507
[JENKINS-43507] Allow SCMSource and SCMNavigator subtypes to share common traits
  • Loading branch information
stephenc committed Jul 5, 2017
2 parents 2cfbf64 + af3d6fd commit dd2b842
Show file tree
Hide file tree
Showing 73 changed files with 6,180 additions and 633 deletions.
14 changes: 12 additions & 2 deletions pom.xml
Expand Up @@ -16,7 +16,7 @@
</licenses>

<artifactId>git</artifactId>
<version>3.3.2-SNAPSHOT</version>
<version>3.4.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>Jenkins Git plugin</name>
<description>Integrates Jenkins with GIT SCM</description>
Expand All @@ -30,7 +30,7 @@
<concurrency>1C</concurrency>
<findbugs.failOnError>false</findbugs.failOnError>
<workflow.version>1.14.2</workflow.version>
<scm-api-plugin.version>2.1.0</scm-api-plugin.version>
<scm-api-plugin.version>2.2.0-beta-1</scm-api-plugin.version>
</properties>

<build>
Expand Down Expand Up @@ -132,12 +132,22 @@
<artifactId>joda-time</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-annotation</artifactId>
<version>1.15</version>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git-client</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -1140,7 +1140,8 @@ public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, Tas

LocalBranch lb = getExtensions().get(LocalBranch.class);
if (lb != null) {
if (lb.getLocalBranch() == null || lb.getLocalBranch().equals("**")) {
String lbn = lb.getLocalBranch();
if (lbn == null || lbn.equals("**")) {
// local branch is configured with empty value or "**" so use remote branch name for checkout
localBranchName = deriveLocalBranchName(remoteBranchName);
}
Expand Down
Expand Up @@ -17,13 +17,49 @@ public class AuthorInChangelog extends FakeGitSCMExtension {
public AuthorInChangelog() {
}

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

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
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";
Expand Down
Expand Up @@ -32,25 +32,72 @@ 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) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

CheckoutOption that = (CheckoutOption) 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{" +
"timeout=" + timeout +
'}';
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return "Advanced checkout behaviours";
Expand Down
@@ -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.
*
Expand All @@ -26,6 +21,9 @@ public class CleanBeforeCheckout extends GitSCMExtension {
public CleanBeforeCheckout() {
}

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

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

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

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

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
/**
* {@inheritDoc}
*/
public String getDisplayName() {
return "Clean before checkout";
}
Expand Down
Expand Up @@ -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.
*
Expand All @@ -22,6 +21,9 @@ public class CleanCheckout extends GitSCMExtension {
public CleanCheckout() {
}

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

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
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";
Expand Down

0 comments on commit dd2b842

Please sign in to comment.