Skip to content
Permalink
Browse files

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 dd2b84217cc967bf908c7f2c02beea27973cd884
Showing with 6,180 additions and 633 deletions.
  1. +12 −2 pom.xml
  2. +2 −1 src/main/java/hudson/plugins/git/GitSCM.java
  3. +36 −0 src/main/java/hudson/plugins/git/extensions/impl/AuthorInChangelog.java
  4. +47 −0 src/main/java/hudson/plugins/git/extensions/impl/CheckoutOption.java
  5. +37 −6 src/main/java/hudson/plugins/git/extensions/impl/CleanBeforeCheckout.java
  6. +37 −2 src/main/java/hudson/plugins/git/extensions/impl/CleanCheckout.java
  7. +73 −7 src/main/java/hudson/plugins/git/extensions/impl/CloneOption.java
  8. +38 −4 src/main/java/hudson/plugins/git/extensions/impl/GitLFSPull.java
  9. +33 −0 src/main/java/hudson/plugins/git/extensions/impl/IgnoreNotifyCommit.java
  10. +42 −1 src/main/java/hudson/plugins/git/extensions/impl/LocalBranch.java
  11. +37 −2 src/main/java/hudson/plugins/git/extensions/impl/PruneStaleBranch.java
  12. +71 −8 src/main/java/hudson/plugins/git/extensions/impl/SubmoduleOption.java
  13. +51 −4 src/main/java/hudson/plugins/git/extensions/impl/UserIdentity.java
  14. +37 −2 src/main/java/hudson/plugins/git/extensions/impl/WipeWorkspace.java
  15. +495 −227 src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
  16. +609 −0 src/main/java/jenkins/plugins/git/GitSCMBuilder.java
  17. +4 −3 src/main/java/jenkins/plugins/git/GitSCMFileSystem.java
  18. +337 −103 src/main/java/jenkins/plugins/git/GitSCMSource.java
  19. +293 −0 src/main/java/jenkins/plugins/git/GitSCMSourceContext.java
  20. +128 −0 src/main/java/jenkins/plugins/git/GitSCMSourceDefaults.java
  21. +112 −0 src/main/java/jenkins/plugins/git/GitSCMSourceRequest.java
  22. +119 −0 src/main/java/jenkins/plugins/git/MethodUtils.java
  23. +60 −0 src/main/java/jenkins/plugins/git/traits/AuthorInChangelogTrait.java
  24. +151 −0 src/main/java/jenkins/plugins/git/traits/BranchDiscoveryTrait.java
  25. +62 −0 src/main/java/jenkins/plugins/git/traits/CheckoutOptionTrait.java
  26. +60 −0 src/main/java/jenkins/plugins/git/traits/CleanAfterCheckoutTrait.java
  27. +60 −0 src/main/java/jenkins/plugins/git/traits/CleanBeforeCheckoutTrait.java
  28. +62 −0 src/main/java/jenkins/plugins/git/traits/CloneOptionTrait.java
  29. +149 −0 src/main/java/jenkins/plugins/git/traits/GitBrowserSCMSourceTrait.java
  30. +60 −0 src/main/java/jenkins/plugins/git/traits/GitLFSPullTrait.java
  31. +74 −0 src/main/java/jenkins/plugins/git/traits/GitSCMExtensionTrait.java
  32. +249 −0 src/main/java/jenkins/plugins/git/traits/GitSCMExtensionTraitDescriptor.java
  33. +172 −0 src/main/java/jenkins/plugins/git/traits/GitToolSCMSourceTrait.java
  34. +119 −0 src/main/java/jenkins/plugins/git/traits/IgnoreOnPushNotificationTrait.java
  35. +78 −0 src/main/java/jenkins/plugins/git/traits/LocalBranchTrait.java
  36. +60 −0 src/main/java/jenkins/plugins/git/traits/PruneStaleBranchTrait.java
  37. +266 −0 src/main/java/jenkins/plugins/git/traits/RefSpecsSCMSourceTrait.java
  38. +242 −0 src/main/java/jenkins/plugins/git/traits/RemoteNameSCMSourceTrait.java
  39. +62 −0 src/main/java/jenkins/plugins/git/traits/SubmoduleOptionTrait.java
  40. +62 −0 src/main/java/jenkins/plugins/git/traits/UserIdentityTrait.java
  41. +60 −0 src/main/java/jenkins/plugins/git/traits/WipeWorkspaceTrait.java
  42. +44 −0 src/main/java/jenkins/plugins/git/traits/package-info.java
  43. +3 −31 src/main/resources/jenkins/plugins/git/GitSCMSource/config-detail.jelly
  44. +1 −0 src/main/resources/jenkins/plugins/git/GitSCMSource/config-detail_en.properties
  45. +1 −0 src/main/resources/jenkins/plugins/git/GitSCMSource/config-detail_en_US.properties
  46. +0 −7 src/main/resources/jenkins/plugins/git/GitSCMSource/config-detail_it.properties
  47. +0 −5 src/main/resources/jenkins/plugins/git/GitSCMSource/config-detail_ja.properties
  48. +0 −38 src/main/resources/jenkins/plugins/git/GitSCMSource/help-excludes.html
  49. +0 −27 src/main/resources/jenkins/plugins/git/GitSCMSource/help-gitTool.html
  50. +0 −27 src/main/resources/jenkins/plugins/git/GitSCMSource/help-ignoreOnPushNotifications.html
  51. +0 −38 src/main/resources/jenkins/plugins/git/GitSCMSource/help-includes.html
  52. +0 −27 src/main/resources/jenkins/plugins/git/GitSCMSource/help-rawRefSpecs.html
  53. +0 −30 src/main/resources/jenkins/plugins/git/GitSCMSource/help-remoteName.html
  54. +4 −0 src/main/resources/jenkins/plugins/git/traits/BranchDiscoveryTrait/config.jelly
  55. +3 −0 src/main/resources/jenkins/plugins/git/traits/BranchDiscoveryTrait/help.html
  56. +30 −0 src/main/resources/jenkins/plugins/git/traits/GitBrowserSCMSourceTrait/config.jelly
  57. +29 −0 src/main/resources/jenkins/plugins/git/traits/GitSCMExtensionTrait/config.jelly
  58. +31 −0 src/main/resources/jenkins/plugins/git/traits/GitToolSCMSourceTrait/config.jelly
  59. +27 −0 src/main/resources/jenkins/plugins/git/traits/LocalBranchTrait/config.jelly
  60. +2 −0 src/main/resources/jenkins/plugins/git/traits/Messages.properties
  61. +31 −0 src/main/resources/jenkins/plugins/git/traits/RefSpecsSCMSourceTrait/RefSpecTemplate/config.jelly
  62. +4 −0 src/main/resources/jenkins/plugins/git/traits/RefSpecsSCMSourceTrait/RefSpecTemplate/help-value.html
  63. +37 −0 src/main/resources/jenkins/plugins/git/traits/RefSpecsSCMSourceTrait/config.jelly
  64. +31 −0 src/main/resources/jenkins/plugins/git/traits/RemoteNameSCMSourceTrait/config.jelly
  65. +0 −1 src/test/java/hudson/plugins/git/browser/GithubWebTest.java
  66. +24 −15 src/test/java/jenkins/plugins/git/AbstractGitSCMSourceRetrieveHeadsTest.java
  67. +62 −14 src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java
  68. +1 −1 src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTrivialTest.java
  69. +598 −0 src/test/java/jenkins/plugins/git/GitSCMBuilderTest.java
  70. +301 −0 src/test/java/jenkins/plugins/git/GitSCMSourceTraitsTest.java
  71. +57 −0 src/test/java/jenkins/plugins/git/traits/GitSCMExtensionTraitTest.java
  72. +5 −0 src/test/resources/jenkins/plugins/git/GitSCMSourceTraitsTest/modern.xml
  73. +96 −0 src/test/resources/jenkins/plugins/git/GitSCMSourceTraitsTest/pimpped_out.xml
14 pom.xml
@@ -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>
@@ -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>
@@ -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>
@@ -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);
}
@@ -17,13 +17,49 @@
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";
@@ -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";
@@ -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,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";
}
@@ -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,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";

0 comments on commit dd2b842

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