From b518828876bab72de78d78cc57e57b05c609de6e Mon Sep 17 00:00:00 2001 From: mcdonan Date: Fri, 12 Jul 2013 13:00:27 +0100 Subject: [PATCH] Ensure github-plugin can auto register hooks with enterprise git, remove the condition which only fetched GitHub instances where the site was official github site, otherwise returned empty collection --- .../com/cloudbees/jenkins/GitHubWebHook.java | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java b/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java index 4fcab0ad9..50bddbfa0 100644 --- a/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java +++ b/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java @@ -54,43 +54,39 @@ public String getUrlName() { * Logs in as the given user and returns the connection object. */ public Iterable login(String host, String userName) { - if (host.equals("github.com")) { - final List l = DescriptorImpl.get().getCredentials(); - - // if the username is not an organization, we should have the right user account on file - for (Credential c : l) { - if (c.username.equals(userName)) - try { - return Collections.singleton(c.login()); - } catch (IOException e) { - LOGGER.log(WARNING,"Failed to login with username="+c.username,e); - return Collections.emptyList(); - } - } + final List l = DescriptorImpl.get().getCredentials(); + + // if the username is not an organization, we should have the right user account on file + for (Credential c : l) { + if (c.username.equals(userName)) + try { + return Collections.singleton(c.login()); + } catch (IOException e) { + LOGGER.log(WARNING,"Failed to login with username="+c.username,e); + return Collections.emptyList(); + } + } - // otherwise try all the credentials since we don't know which one would work - return new Iterable() { - public Iterator iterator() { - return new FilterIterator( - new AdaptedIterator(l) { - protected GitHub adapt(Credential c) { - try { - return c.login(); - } catch (IOException e) { - LOGGER.log(WARNING,"Failed to login with username="+c.username,e); - return null; - } + // otherwise try all the credentials since we don't know which one would work + return new Iterable() { + public Iterator iterator() { + return new FilterIterator( + new AdaptedIterator(l) { + protected GitHub adapt(Credential c) { + try { + return c.login(); + } catch (IOException e) { + LOGGER.log(WARNING,"Failed to login with username="+c.username,e); + return null; } - }) { - protected boolean filter(GitHub g) { - return g!=null; } - }; - } - }; - } else { - return Collections. emptyList(); - } + }) { + protected boolean filter(GitHub g) { + return g!=null; + } + }; + } + }; } /*