/** * Create a {@link org.eclipse.jgit.fnmatch.FileNameMatcher} instance which * uses the same pattern like this matcher, but has the current state of * this matcher as reset and start point * * @return a {@link org.eclipse.jgit.fnmatch.FileNameMatcher} instance which * uses the same pattern like this matcher, but has the current * state of this matcher as reset and start point. */ public FileNameMatcher createMatcherForSuffix() { final List<Head> copyOfHeads = new ArrayList<>(heads.size()); copyOfHeads.addAll(heads); return new FileNameMatcher(copyOfHeads); }
private static boolean patternMatchesHost(String pattern, String name) { if (pattern.indexOf('*') >= 0 || pattern.indexOf('?') >= 0) { final FileNameMatcher fn; try { fn = new FileNameMatcher(pattern, null); } catch (InvalidPatternException e) { return false; } fn.append(name); return fn.isMatch(); } else { // Not a pattern but a full host name return pattern.equals(name); } }
/** * * @return a {@link FileNameMatcher} instance which uses the same pattern * like this matcher, but has the current state of this matcher as * reset and start point. */ public FileNameMatcher createMatcherForSuffix() { final List<Head> copyOfHeads = new ArrayList<Head>(heads.size()); copyOfHeads.addAll(heads); return new FileNameMatcher(copyOfHeads); }
/** * Create a {@link org.eclipse.jgit.fnmatch.FileNameMatcher} instance which * uses the same pattern like this matcher, but has the current state of * this matcher as reset and start point * * @return a {@link org.eclipse.jgit.fnmatch.FileNameMatcher} instance which * uses the same pattern like this matcher, but has the current * state of this matcher as reset and start point. */ public FileNameMatcher createMatcherForSuffix() { final List<Head> copyOfHeads = new ArrayList<>(heads.size()); copyOfHeads.addAll(heads); return new FileNameMatcher(copyOfHeads); }
private static boolean patternMatchesHost(String pattern, String name) { if (pattern.indexOf('*') >= 0 || pattern.indexOf('?') >= 0) { final FileNameMatcher fn; try { fn = new FileNameMatcher(pattern, null); } catch (InvalidPatternException e) { return false; } fn.append(name); return fn.isMatch(); } else { // Not a pattern but a full host name return pattern.equals(name); } }
private static boolean isHostMatch(final String pattern, final String name) { final FileNameMatcher fn; try { fn = new FileNameMatcher(pattern, null); } catch (InvalidPatternException e) { return false; } fn.append(name); return fn.isMatch(); }
private void removeFromList(Set<String> current, String key, String patterns) { for (String toRemove : patterns.split("\\s*,\\s*")) { //$NON-NLS-1$ if (toRemove.indexOf('*') < 0 && toRemove.indexOf('?') < 0) { current.remove(toRemove); continue; } try { FileNameMatcher matcher = new FileNameMatcher(toRemove, null); for (Iterator<String> i = current.iterator(); i.hasNext();) { matcher.reset(); matcher.append(i.next()); if (matcher.isMatch()) { i.remove(); } } } catch (InvalidPatternException e) { log.warn(format(SshdText.get().configInvalidPattern, key, toRemove)); } } }
public GitConverter(@NotNull DB cache, @NotNull Path basePath, @NotNull String[] globs) throws IOException, InvalidPatternException { this.basePath = basePath; this.cache = cache; this.globs = globs.clone(); this.matchers = convertGlobs(globs); Arrays.sort(globs); for (String glob : globs) { new FileNameMatcher(glob, '/'); } tempPath = basePath.resolve("lfs/tmp"); Files.createDirectories(tempPath); //noinspection unchecked cacheMeta = cache.<String, MetaData>hashMap("meta") .keySerializer(Serializer.STRING) .valueSerializer(new SerializerJava()) .createOrOpen(); }
/** {@inheritDoc} */ @Override public Set<String> getTagNames(String tagPattern) throws GitException { if (tagPattern == null) tagPattern = "*"; Set<String> tags = new HashSet<>(); try (Repository repo = getRepository()) { FileNameMatcher matcher = new FileNameMatcher(tagPattern, null); Map<String, Ref> tagList = repo.getTags(); for (String name : tagList.keySet()) { matcher.reset(); matcher.append(name); if (matcher.isMatch()) tags.add(name); } } catch (InvalidPatternException e) { throw new GitException(e); } return tags; }
/** {@inheritDoc} */ @Override public Set<String> getRemoteTagNames(String tagPattern) throws GitException { /* BUG: Lists local tag names, not remote tag names */ if (tagPattern == null) tagPattern = "*"; try (Repository repo = getRepository()) { Set<String> tags = new HashSet<>(); FileNameMatcher matcher = new FileNameMatcher(tagPattern, '/'); List<Ref> refList = repo.getRefDatabase().getRefsByPrefix(R_TAGS); for (Ref ref : refList) { String name = ref.getName().substring(R_TAGS.length()); matcher.reset(); matcher.append(name); if (matcher.isMatch()) tags.add(name); } return tags; } catch (IOException | InvalidPatternException e) { throw new GitException(e); } }