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

Unified Diff: lib/src/package.dart

Issue 1233533002: Respect gitignore for packages in subdirectories. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | test/package_list_files_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/package.dart
diff --git a/lib/src/package.dart b/lib/src/package.dart
index f713e9f4a1fe5992efb8dbb528898ba055d8e280..b9ecb1d29a40890bf4fc8e49df8602fb206de76d 100644
--- a/lib/src/package.dart
+++ b/lib/src/package.dart
@@ -108,6 +108,25 @@ class Package {
}));
}
+ /// Returns whether or not this package is in a Git repo.
+ bool get _usesGit {
Bob Nystrom 2015/07/10 00:34:34 "uses" is kind of weird. How about "_inGitRepo"?
nweiz 2015/07/10 21:44:10 Done.
+ if (_usesGitCache != null) return _usesGitCache;
+
+ if (dir == null || !git.isInstalled) {
+ _usesGitCache = false;
+ } else {
+ try {
+ git.runSync(['rev-parse'], workingDir: dir);
+ _usesGitCache = true;
+ } on git.GitException catch (_) {
+ _usesGitCache = false;
+ }
+ }
+
+ return _usesGitCache;
+ }
+ bool _usesGitCache;
+
/// Loads the package whose root directory is [packageDir].
///
/// [name] is the expected name of that package (e.g. the name given in the
@@ -207,7 +226,7 @@ class Package {
// path package, since re-parsing a path is very expensive relative to
// string operations.
var files;
- if (useGitIgnore && git.isInstalled && dirExists(path('.git'))) {
+ if (useGitIgnore && git.isInstalled && _usesGit) {
Bob Nystrom 2015/07/10 00:34:34 You can remove the git.isInstalled check here now.
nweiz 2015/07/10 21:44:10 Done.
// Later versions of git do not allow a path for ls-files that appears to
// be outside of the repo, so make sure we give it a relative path.
var relativeBeneath = p.relative(beneath, from: dir);
« no previous file with comments | « no previous file | test/package_list_files_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698