Skip to content
Permalink
Browse files

Merge pull request #475 from jbq/scm_source_compat

[JENKINS-42204] GitSCMSource: Fix backwards compatibility for advanced options.
  • Loading branch information
MarkEWaite committed Feb 24, 2017
2 parents d780f27 + fa9190d commit 608a378e37bfca1692d23751955de0a9e998f9b2
Showing with 18 additions and 15 deletions.
  1. +18 −15 src/main/java/jenkins/plugins/git/GitSCMSource.java
@@ -79,17 +79,22 @@
import java.io.PrintWriter;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import static org.apache.commons.lang.StringUtils.isBlank;

/**
* @author Stephen Connolly
*/
public class GitSCMSource extends AbstractGitSCMSource {
private static final String DEFAULT_INCLUDES = "*";

private static final String DEFAULT_EXCLUDES = "";

public static final Logger LOGGER = Logger.getLogger(GitSCMSource.class.getName());

private final String remote;
@@ -119,19 +124,8 @@ public GitSCMSource(String id, String remote, String credentialsId, String remot
super(id);
this.remote = remote;
this.credentialsId = credentialsId;

if (remoteName == null)
// backwards compatibility
this.remoteName = "origin";
else
this.remoteName = remoteName;

if (rawRefSpecs == null)
// backwards compatibility
this.rawRefSpecs = String.format("+refs/heads/*:refs/remotes/%s/*", this.remoteName);
else
this.rawRefSpecs = rawRefSpecs;

this.remoteName = remoteName;
this.rawRefSpecs = rawRefSpecs;
this.includes = includes;
this.excludes = excludes;
this.ignoreOnPushNotifications = ignoreOnPushNotifications;
@@ -195,6 +189,10 @@ public String getRemote() {

@Override
public String getRemoteName() {
if (isBlank(remoteName))
// backwards compatibility
return super.getRemoteName();

return remoteName;
}

@@ -215,8 +213,13 @@ public String getExcludes() {
@Override
protected List<RefSpec> getRefSpecs() {
List<RefSpec> refSpecs = new ArrayList<>();
String refSpecsString = rawRefSpecs;

if (isBlank(refSpecsString))
// backwards compatibility
refSpecsString = String.format("+refs/heads/*:refs/remotes/%s/*", getRemoteName());

for (String rawRefSpec : rawRefSpecs.split(" ")) {
for (String rawRefSpec : refSpecsString.split(" ")) {
refSpecs.add(new RefSpec(rawRefSpec));
}

0 comments on commit 608a378

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