@@ -0,0 +1,2711 @@
+package hudson.plugins.git;%0A%0Aimport hudson.Extension;%0Aimport hudson.model.AbstractModelObject;%0Aimport hudson.model.AbstractProject;%0Aimport hudson.model.Hudson;%0Aimport hudson.model.RootAction;%0A%0Aimport hudson.scm.SCM;%0Aimport hudson.triggers.SCMTrigger;%0A%0Aimport org.spearce.jgit.transport.RemoteConfig;%0Aimport org.spearce.jgit.transport.URIish;%0A%0Aimport org.kohsuke.stapler.StaplerRequest;%0Aimport org.kohsuke.stapler.StaplerResponse;%0A%0Aimport javax.servlet.ServletException;%0Aimport static javax.servlet.http.HttpServletResponse.SC_OK;%0Aimport java.io.IOException;%0A%0Aimport java.util.logging.Logger;%0Aimport static java.util.logging.Level.INFO;%0A%0A/**%0A * Information screen for the use of Git in Hudson.%0A */%0A@Extension%0Apublic class GitStatus extends AbstractModelObject implements RootAction %7B%0A    public String getDisplayName() %7B%0A        return %22Git%22;%0A    %7D%0A%0A    public String getSearchUrl() %7B%0A        return getUrlName();%0A    %7D%0A%0A    public String getIconFileName() %7B%0A        // TODO%0A        return null;%0A    %7D%0A%0A    public String getUrlName() %7B%0A        return %22git%22;%0A    %7D%0A%0A    public void doNotifyCommit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException %7B%0A        String urlString = req.getParameter(%22url%22);%0A%09URIish url = null;%0A        try %7B%0A            url = new URIish(urlString);%0A        %7D catch (java.net.URISyntaxException e) %7B %7D%0A%0A        boolean scmFound = false,%0A                triggerFound = false,%0A                urlFound = false;%0A        for (AbstractProject%3C?,?%3E project : Hudson.getInstance().getItems(AbstractProject.class)) %7B%0A            SCM scm = project.getScm();%0A            if (scm instanceof GitSCM) scmFound = true; else continue;%0A%0A            SCMTrigger trigger = project.getTrigger(SCMTrigger.class);%0A            if (trigger!=null) triggerFound = true; else continue;%0A%0A            GitSCM git = (GitSCM) scm;%0A            for (RemoteConfig repository : git.getRepositories()) %7B%0A                boolean repositoryMatches = false;%0A                for (URIish remoteURL : repository.getURIs()) %7B%0A                    if (url.equals(remoteURL)) %7B repositoryMatches = true; break; %7D%0A                %7D%0A                if (repositoryMatches) urlFound = true; else continue;%0A%0A                trigger.run();%0A            %7D%0A        %7D%0A%0A        if (url == null)    LOGGER.warning(%22Couldn't read url: %22 + urlString);%0A        else if (!scmFound) LOGGER.warning(%22No git jobs found%22);%0A        else if (!triggerFound) LOGGER.warning(%22No git jobs using SCM polling%22);%0A        else if (!urlFound) LOGGER.warning(%22No git jobs using repository: %22 + url.toString());%0A%0A        rsp.setStatus(SC_OK);%0A    %7D%0A%0A    private static final Logger LOGGER = Logger.getLogger(GitStatus.class.getName());%0A%7D%0A%0A

Add an action extension to remotely trigger a poll for a given git repository