Skip to content

Commit

Permalink
[JENKINS-32749] XSTREAM aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Recena committed Feb 16, 2016
1 parent 4f14b84 commit 438bb6f
Showing 1 changed file with 28 additions and 20 deletions.
Expand Up @@ -34,28 +34,16 @@
import hudson.Extension;
import hudson.Util;
import hudson.console.HyperlinkNote;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import hudson.model.TaskListener;
import hudson.security.ACL;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.net.ssl.SSLHandshakeException;

import jenkins.plugins.git.AbstractGitSCMSource;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMHeadObserver;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import jenkins.scm.api.SCMSourceCriteria;
import jenkins.scm.api.SCMSourceDescriptor;
import jenkins.scm.api.SCMSourceOwner;
Expand All @@ -76,6 +64,21 @@
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.net.ssl.SSLHandshakeException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import static hudson.model.Items.XSTREAM2;

public class GitHubSCMSource extends AbstractGitSCMSource {

private final String apiUri;
Expand Down Expand Up @@ -250,9 +253,9 @@ protected void doRetrieve(SCMHeadObserver observer, TaskListener listener, GHRep
if (criteria != null) {
SCMSourceCriteria.Probe probe = getProbe(branchName, "branch", "refs/heads/" + branchName, repo, listener);
if (criteria.isHead(probe, listener)) {
listener.getLogger().format(" Met criteria%n%n");
listener.getLogger().format(" Met criteria%n");
} else {
listener.getLogger().format(" Does not meet criteria%n%n");
listener.getLogger().format(" Does not meet criteria%n");
continue;
}
}
Expand All @@ -264,7 +267,7 @@ protected void doRetrieve(SCMHeadObserver observer, TaskListener listener, GHRep
}
branches++;
}
listener.getLogger().format(" %d branches were processed%n", branches);
listener.getLogger().format("%n %d branches were processed%n", branches);

listener.getLogger().format("%n Getting remote pull requests...%n");
int pullrequests = 0;
Expand All @@ -286,9 +289,9 @@ protected void doRetrieve(SCMHeadObserver observer, TaskListener listener, GHRep
if (criteria != null) {
SCMSourceCriteria.Probe probe = getProbe(branchName, "pull request", "refs/pull/" + number + "/head", repo, listener);
if (criteria.isHead(probe, listener)) {
listener.getLogger().format(" Met criteria%n%n");
listener.getLogger().format(" Met criteria%n");
} else {
listener.getLogger().format(" Does not meet criteria%n%n");
listener.getLogger().format(" Does not meet criteria%n");
continue;
}
}
Expand All @@ -299,7 +302,7 @@ protected void doRetrieve(SCMHeadObserver observer, TaskListener listener, GHRep
}
pullrequests++;
}
listener.getLogger().format(" %d pull requests were processed%n", pullrequests);
listener.getLogger().format("%n %d pull requests were processed%n", pullrequests);

}

Expand Down Expand Up @@ -371,6 +374,11 @@ protected SCMRevision doRetrieve(SCMHead head, TaskListener listener, GHReposito
public static final String ANONYMOUS = "ANONYMOUS";
public static final String SAME = "SAME";

@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void addAliases() {
XSTREAM2.addCompatibilityAlias("org.jenkinsci.plugins.github_branch_source.OriginGitHubSCMSource", GitHubSCMSource.class);
}

@Override
public String getDisplayName() {
return "GitHub";
Expand Down

0 comments on commit 438bb6f

Please sign in to comment.