Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 342553002: Respect git's ignore rules pervasively in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review, performance improvements Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/utils.dart
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 0ec5e46286bcedbe52368558ac49653d55e56519..b96afdf0d8ce54bf523a1c69d5b824000dfeef89 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -329,6 +329,34 @@ Future<Map> mapMapAsync(Map map, {key(key, value), value(key, value)}) {
value: (mapKey) => value(mapKey, map[mapKey]));
}
+/// Given a list of filenames, returns a set of patterns that can be used to
+/// filter for those filenames.
+///
+/// For a given path, that path ends with some string in the returned set if
+/// and only if that path's basename is in [files].
+Set<String> createFileFilter(Iterable<String> files) {
+ return files.expand((file) {
+ var result = ["/$file"];
+ if (Platform.operatingSystem == 'windows') result.add("\\$file");
+ return result;
+ }).toSet();
+}
+
+/// Given a blacklist of directory names, returns a set of patterns that can
+/// be used to filter for those directory names.
+///
+/// For a given path, that path contains some string in the returned set if
+/// and only if one of that path's components is in [dirs].
+Set<String> createDirectoryFilter(Iterable<String> dirs) {
+ return dirs.expand((dir) {
+ var result = ["/$dir/"];
+ if (Platform.operatingSystem == 'windows') {
+ result..add("/$dir\\")..add("\\$dir/")..add("\\$dir\\");
+ }
+ return result;
+ }).toSet();
+}
+
/// Returns the shortest path from [start] to [end] in [graph].
///
/// The graph is represented by a map where each key is a vertex and the value
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/package.dart ('k') | sdk/lib/_internal/pub/lib/src/validator/compiled_dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698