Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding 'Root Module' option for FishEye integration

  • Loading branch information...
commit d15efe6b5d1acff3ec84fa9b7be288af6bf34410 1 parent 3e15983
@rpetti rpetti authored
View
27 src/main/java/hudson/plugins/perforce/browsers/FishEyePerforce.java
@@ -28,9 +28,16 @@
*/
public final URL url;
+ /**
+ * This is the root 'module' of the FishEye repository.
+ * It is a path that is trimmed from the beginning of depot paths for files.
+ */
+ public final String rootModule;
+
@DataBoundConstructor
- public FishEyePerforce(URL url) {
+ public FishEyePerforce(URL url, String rootModule) {
this.url = normalizeToEndWithSlash(url);
+ this.rootModule = trimHeadSlash(trimHeadSlash(rootModule));
}
@Override
@@ -47,12 +54,12 @@ public URL getDiffLink(Changelist.FileEntry file) throws IOException {
}
if(r <= 1)
return null;
- return new URL(url, trimHeadSlash(trimHeadSlash(file.getFilename())) + new QueryBuilder(url.getQuery()).add("r1=").add("r2=" + r));
+ return new URL(url, getRelativeFilename(file) + new QueryBuilder(url.getQuery()).add("r1=").add("r2=" + r));
}
@Override
public URL getFileLink(Changelist.FileEntry file) throws IOException {
- return new URL(url, trimHeadSlash(trimHeadSlash(file.getFilename())) + new QueryBuilder(url.getQuery()));
+ return new URL(url, getRelativeFilename(file) + new QueryBuilder(url.getQuery()));
}
@Override
@@ -60,6 +67,14 @@ public URL getChangeSetLink(PerforceChangeLogEntry change) throws IOException {
return new URL(url,"../../changelog/"+getProjectName()+"/?cs="+change.getChange().getChangeNumber());
}
+ private String getRelativeFilename(Changelist.FileEntry file) {
+ String path = trimHeadSlash(trimHeadSlash(file.getFilename()));
+ if(path.startsWith(getRootModule())){
+ path = path.substring(getRootModule().length());
+ }
+ return trimHeadSlash(path);
+ }
+
/**
* Pick up "FOOBAR" from "http://site/browse/FOOBAR/"
*/
@@ -71,6 +86,12 @@ private String getProjectName() {
return p.substring(idx+1);
}
+ public String getRootModule() {
+ if(rootModule==null)
+ return "";
+ return rootModule;
+ }
+
@Extension
public static class DescriptorImpl extends Descriptor<RepositoryBrowser<?>> {
View
3  src/main/resources/hudson/plugins/perforce/browsers/FishEyePerforce/config.jelly
@@ -3,4 +3,7 @@
<f:textbox name="fisheye.perforce.url" value="${browser.url}"
checkUrl="'${rootURL}/repositoryBrowser/FishEyePerforce/check?value='+escape(this.value)"/>
</f:entry>
+ <f:entry title="${%Root module}" field="rootModule" help="/plugin/perforce/help/browsers/fisheye/rootModule.html">
+ <f:textbox />
+ </f:entry>
</j:jelly>
View
4 src/main/webapp/help/browsers/fisheye/rootModule.html
@@ -0,0 +1,4 @@
+<div>
+ Specify the root module of this Project in FishEye. Sometimes the FishEye repository is set up so the root doesn't correspond to the root of the perforce server. This option trims the real root location off the file urls so they resolve correctly in FishEye.
+ (Example: <tt>depot/project</tt>)
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.