Skip to content

Commit

Permalink
[JENKINS-7044] Add OpenGrok repository browser to CVS plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mc1arke committed Sep 10, 2012
1 parent 50165bf commit 1a2df15
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/main/java/hudson/scm/browsers/OpenGrok.java
@@ -0,0 +1,72 @@
/*
* The MIT License
*
* Copyright (c) 2012, Michael Clarke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.scm.browsers;

import hudson.Extension;
import hudson.model.Descriptor;
import hudson.scm.CVSChangeLogSet;
import hudson.scm.CVSRepositoryBrowser;
import hudson.scm.RepositoryBrowser;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public final class OpenGrok extends CVSRepositoryBrowser {
public final URL url;

@DataBoundConstructor
public OpenGrok(URL url) throws MalformedURLException {
this.url = normalizeToEndWithSlash(url);
}


public URL getFileLink(CVSChangeLogSet.File file) throws IOException {
return new URL(url,"xref/ "+ file.getName() + param().add("r = " + file.getRevision()));
}

public URL getDiffLink(CVSChangeLogSet.File file) throws IOException {
CVSChangeLogSet.Revision r = new CVSChangeLogSet.Revision(file.getRevision());
CVSChangeLogSet.Revision p = r.getPrevious();
if(p==null) return null;

return new URL(getFileLink(file), file.getSimpleName()+".diff"+param().add("r1="+p).add("r2="+r));
}

public URL getChangeSetLink(CVSChangeLogSet.CVSChangeLog changeSet) throws IOException {
return null;
}

private QueryBuilder param() {
return new QueryBuilder(url.getQuery());
}

@Extension
public static class DescriptorImpl extends Descriptor<RepositoryBrowser<?>> {
public String getDisplayName() {
return "OpenGrok";
}
}
}
31 changes: 31 additions & 0 deletions src/main/resources/hudson/scm/browsers/OpenGrok/config.jelly
@@ -0,0 +1,31 @@
<!--
The MIT License
Copyright (c) 20012, Michael Clarke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"
xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson"
xmlns:f="/lib/form">
<f:entry title="URL" field="url">
<f:textbox />
</f:entry>
</j:jelly>
3 changes: 3 additions & 0 deletions src/main/resources/hudson/scm/browsers/OpenGrok/help-url.html
@@ -0,0 +1,3 @@
<div>
Specify the root URL of OpenGrok for this repository.
</div>

0 comments on commit 1a2df15

Please sign in to comment.