|
@@ -83,6 +83,7 @@ |
|
|
import jenkins.scm.api.trait.SCMHeadPrefilter; |
|
|
import jenkins.scm.api.trait.SCMSourceTrait; |
|
|
import jenkins.scm.api.trait.SCMSourceTraitDescriptor; |
|
|
import jenkins.scm.api.trait.SCMTrait; |
|
|
import jenkins.scm.impl.form.NamedArrayList; |
|
|
import jenkins.scm.impl.trait.Discovery; |
|
|
import jenkins.scm.impl.trait.Selection; |
|
@@ -162,7 +163,7 @@ public void setCredentialsId(@CheckForNull String credentialsId) { |
|
|
|
|
|
@DataBoundSetter |
|
|
public void setTraits(List<SCMSourceTrait> traits) { |
|
|
this.traits = traits == null ? new ArrayList<SCMSourceTrait>() : new ArrayList<SCMSourceTrait>(traits); |
|
|
this.traits = SCMTrait.asSetList(traits); |
|
|
} |
|
|
|
|
|
@Deprecated |
|
@@ -172,7 +173,7 @@ public GitSCMSource(String id, String remote, String credentialsId, String remot |
|
|
super(id); |
|
|
this.remote = remote; |
|
|
this.credentialsId = credentialsId; |
|
|
this.traits = new ArrayList<>(); |
|
|
List<SCMSourceTrait> traits = new ArrayList<>(); |
|
|
this.traits.add(new BranchDiscoveryTrait()); |
|
|
if (!DEFAULT_INCLUDES.equals(includes) || !DEFAULT_EXCLUDES.equals(excludes)) { |
|
|
traits.add(new WildcardSCMHeadFilterTrait(includes, excludes)); |
|
@@ -187,6 +188,7 @@ public GitSCMSource(String id, String remote, String credentialsId, String remot |
|
|
if (trait != null) { |
|
|
traits.add(trait); |
|
|
} |
|
|
setTraits(traits); |
|
|
} |
|
|
|
|
|
@Deprecated |
|
@@ -198,7 +200,7 @@ public GitSCMSource(String id, String remote, String credentialsId, String inclu |
|
|
|
|
|
private Object readResolve() throws ObjectStreamException { |
|
|
if (traits == null) { |
|
|
traits = new ArrayList<>(); |
|
|
List<SCMSourceTrait> traits = new ArrayList<>(); |
|
|
traits.add(new BranchDiscoveryTrait()); |
|
|
if ((includes != null && !DEFAULT_INCLUDES.equals(includes)) |
|
|
|| (excludes != null && !DEFAULT_EXCLUDES.equals(excludes))) { |
|
@@ -244,6 +246,7 @@ private Object readResolve() throws ObjectStreamException { |
|
|
if (trait != null) { |
|
|
traits.add(trait); |
|
|
} |
|
|
setTraits(traits); |
|
|
} |
|
|
return this; |
|
|
} |
|
@@ -279,19 +282,15 @@ private RefSpecsSCMSourceTrait asRefSpecsSCMSourceTrait(String rawRefSpecs, Stri |
|
|
@Restricted(DoNotUse.class) |
|
|
@RestrictedSince("3.4.0") |
|
|
public boolean isIgnoreOnPushNotifications() { |
|
|
for (SCMSourceTrait trait : traits) { |
|
|
if (trait instanceof IgnoreOnPushNotificationTrait) { |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return SCMTrait.find(traits, IgnoreOnPushNotificationTrait.class) != null; |
|
|
} |
|
|
|
|
|
|
|
|
// For Stapler only |
|
|
@Restricted(DoNotUse.class) |
|
|
@DataBoundSetter |
|
|
public void setBrowser(GitRepositoryBrowser browser) { |
|
|
List<SCMSourceTrait> traits = new ArrayList<>(this.traits); |
|
|
for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) { |
|
|
if (iterator.next() instanceof GitBrowserSCMSourceTrait) { |
|
|
iterator.remove(); |
|
@@ -300,12 +299,14 @@ public void setBrowser(GitRepositoryBrowser browser) { |
|
|
if (browser != null) { |
|
|
traits.add(new GitBrowserSCMSourceTrait(browser)); |
|
|
} |
|
|
setTraits(traits); |
|
|
} |
|
|
|
|
|
// For Stapler only |
|
|
@Restricted(DoNotUse.class) |
|
|
@DataBoundSetter |
|
|
public void setGitTool(String gitTool) { |
|
|
List<SCMSourceTrait> traits = new ArrayList<>(this.traits); |
|
|
gitTool = Util.fixEmptyAndTrim(gitTool); |
|
|
for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) { |
|
|
if (iterator.next() instanceof GitToolSCMSourceTrait) { |
|
@@ -315,13 +316,15 @@ public void setGitTool(String gitTool) { |
|
|
if (gitTool != null) { |
|
|
traits.add(new GitToolSCMSourceTrait(gitTool)); |
|
|
} |
|
|
setTraits(traits); |
|
|
} |
|
|
|
|
|
// For Stapler only |
|
|
@Restricted(DoNotUse.class) |
|
|
@DataBoundSetter |
|
|
@Deprecated |
|
|
public void setExtensions(@CheckForNull List<GitSCMExtension> extensions) { |
|
|
List<SCMSourceTrait> traits = new ArrayList<>(this.traits); |
|
|
for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) { |
|
|
if (iterator.next() instanceof GitSCMExtensionTrait) { |
|
|
iterator.remove(); |
|
@@ -349,6 +352,7 @@ public void setExtensions(@CheckForNull List<GitSCMExtension> extensions) { |
|
|
+ "make sense for a GitSCMSource)", extension.getClass().getName()); |
|
|
} |
|
|
} |
|
|
setTraits(traits); |
|
|
} |
|
|
|
|
|
@Override |
|
|