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)); } } }
/** {@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); } }