package org.jenkinsci.plugins.p4_client.filters; import hudson.Extension; import hudson.model.AutoCompletionCandidates; import java.util.List; import org.jenkinsci.plugins.p4_client.client.ConnectionFactory; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import com.perforce.p4java.core.IDepot; import com.perforce.p4java.core.file.FileSpecBuilder; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.option.server.GetDepotFilesOptions; import com.perforce.p4java.option.server.GetDirectoriesOptions; import com.perforce.p4java.server.IOptionsServer; public class FilterPathImpl extends Filter { private final String path; @DataBoundConstructor public FilterPathImpl(String path) { this.path = path; } public String getPath() { return path; } @Extension public static final class DescriptorImpl extends FilterDescriptor { @Override public String getDisplayName() { return "Exclude changes from Depot path"; } public AutoCompletionCandidates doAutoCompletePath( @QueryParameter String value) { if (!value.startsWith("//")) { return null; } // remove leading '//' markers for depot matching String depot = value.substring(2); if (!depot.contains("/")) { return listDepots(depot); } AutoCompletionCandidates c = new AutoCompletionCandidates(); listDirs(value, c); listFiles(value, c); return c; } private AutoCompletionCandidates listDepots(String value) { AutoCompletionCandidates c = new AutoCompletionCandidates(); try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null) { List<IDepot> list = iserver.getDepots(); for (IDepot l : list) { if (l.getName().startsWith(value)) { c.add("//" + l.getName()); } } } } catch (Exception e) { } return c; } private void listDirs(String value, AutoCompletionCandidates c) { try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null && value.length() > 4) { List<IFileSpec> dirs; dirs = FileSpecBuilder.makeFileSpecList(value + "*"); GetDirectoriesOptions opts = new GetDirectoriesOptions(); List<IFileSpec> list = iserver.getDirectories(dirs, opts); if (list == null) { return; } if (list.size() > 10) { list = list.subList(0, 10); } for (IFileSpec l : list) { String dir = l.getOriginalPathString(); if (dir != null) { c.add(dir); } } } } catch (Exception e) { } } private void listFiles(String value, AutoCompletionCandidates c) { try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null && value.length() > 4) { List<IFileSpec> files; files = FileSpecBuilder.makeFileSpecList(value + "..."); GetDepotFilesOptions opts = new GetDepotFilesOptions(); opts.setMaxResults(10); List<IFileSpec> list = iserver.getDepotFiles(files, opts); for (IFileSpec l : list) { c.add(l.getDepotPathString()); } } } catch (Exception e) { } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#2 | 9133 | Paul Allen |
Added Workspace mode for versioned Client Specs. Client Spec can be specified by depot path and used to configure workspace for build. - Includes fix for removing header when using p4 print. |
||
#1 | 9091 | Paul Allen |
Added Changelist build filtering for SCM polling: - Configuration uses 'repeatableHeteroProperty' - Filter on Perforce username - Filter on Perforce Depot path (no wildcard support) |