Chromium Code Reviews| 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); |