Index: src/main/java/hudson/plugins/bazaar/BazaarRepositoryBrowser.java =============================================================== --- src/main/java/hudson/plugins/bazaar/BazaarRepositoryBrowser.java (revision 30369) +++ src/main/java/hudson/plugins/bazaar/BazaarRepositoryBrowser.java (working copy) @@ -30,4 +30,11 @@ public abstract class BazaarRepositoryBrowser extends RepositoryBrowser + */ +public class OpenGrok extends BazaarRepositoryBrowser { + + /** + * The URL of the OpenGrok repository. + * + * This is normally like http://src.opensolaris.org/source/ + * Normalized to have '/' at the tail. + */ + public final URL url; + + /** + * Root Bazaar module name (like 'foo/bar' — normalized to + * have no leading nor trailing slash.) Can be empty. + */ + private final String rootModule; + + @DataBoundConstructor + public OpenGrok(URL url, String rootModule) { + this.url = normalizeToEndWithSlash(url); + + // normalize + rootModule = rootModule.trim(); + if(rootModule.startsWith("/")) + rootModule = rootModule.substring(1); + if(rootModule.endsWith("/")) + rootModule = rootModule.substring(0,rootModule.length()-1); + + this.rootModule = rootModule; + } + + @Override + public URL getChangeSetLink(BazaarChangeSet changeSet) throws IOException { + return null; + } + + @Override + public URL getDiffLink(BazaarAffectedFile affectedFile) throws IOException { + URL url = null; + String path = affectedFile.getPath().trim(); + if (affectedFile.getEditType() == EditType.EDIT && ! isFolderPath(path) && ! isRenaming(affectedFile)) { + int revision = extractRevision(affectedFile); + path = getFullPath(path); + url = new URL(this.url, String.format("./diff/%s?r1=/%s@%s&r2=/%s@%s",path, + path, + revision-1, + path, + revision)); + } + return url; + } + + @Override + public URL getFileLink(BazaarAffectedFile affectedFile) throws IOException { + URL url = null; + String path = affectedFile.getPath().trim(); + if (affectedFile.getEditType() == EditType.EDIT && ! isFolderPath(path) && ! isRenaming(affectedFile)) { + int revision = extractRevision(affectedFile); + path = getFullPath(path); + url = new URL(this.url, String.format("./xref/%s?r=%s", path, revision)); + } + return url; + } + + private static int extractRevision(BazaarAffectedFile affectedFile) { + return Integer.valueOf(affectedFile.getChangeSet().getRevision()); + } + + private String getFullPath(String path) { + return this.rootModule + "/" + path; + } + + @Extension + public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl(); + + public Descriptor> getDescriptor() { + return DESCRIPTOR; + } + + public static class DescriptorImpl extends Descriptor> { + public DescriptorImpl() { + super(OpenGrok.class); + } + + @Override + public String getDisplayName() { + return "OpenGrok"; + } + } +} Index: src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/config.jelly =============================================================== --- src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/config.jelly (revision 0) +++ src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/config.jelly (revision 0) @@ -0,0 +1,8 @@ + + + + + + + + Index: src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-rootModule.html =============================================================== --- src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-rootModule.html (revision 0) +++ src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-rootModule.html (revision 0) @@ -0,0 +1,5 @@ +
+ Specify the root Bazaar module that this OpenGrok monitors. + For example, for http://src.opensolaris.org/source/xref/opengrok/trunk/, + this field would be opengrok/trunk/ because it displays the directory "/opengrok/trunk/". +
\ No newline at end of file Index: src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-rootModule_fr.html =============================================================== --- src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-rootModule_fr.html (revision 0) +++ src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-rootModule_fr.html (revision 0) @@ -0,0 +1,5 @@ +
+ Spécifiez ici le module racine Bazaar que cet OpenGrok obsverve. + Par exemple, pour http://src.opensolaris.org/source/xref/opengrok/trunk/, + ce champ serait opengrok/trunk car il affiche le répertoire "/opengrok/trunk". +
\ No newline at end of file Index: src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-url.html =============================================================== --- src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-url.html (revision 0) +++ src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-url.html (revision 0) @@ -0,0 +1,5 @@ +
+ The repository browser URL for the root of the project. + For example, the OpenGrok project would use + http://src.opensolaris.org/source/. +
Index: src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-url_fr.html =============================================================== --- src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-url_fr.html (revision 0) +++ src/main/resources/hudson/plugins/bazaar/browsers/OpenGrok/help-url_fr.html (revision 0) @@ -0,0 +1,5 @@ +
+ L'URL racine du projet pour le navigateur de l'outil de gestion de configuration du code. + Par exemple, pour le projet OpenGrok : + http://src.opensolaris.org/source/. +