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

Side by Side Diff: lib/src/package.dart

Issue 1317043002: React gracefully to a fully-.gitignored package. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « lib/src/git.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub.package; 5 library pub.package;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 })); 108 }));
109 } 109 }
110 110
111 /// Returns whether or not this package is in a Git repo. 111 /// Returns whether or not this package is in a Git repo.
112 bool get _inGitRepo { 112 bool get _inGitRepo {
113 if (_inGitRepoCache != null) return _inGitRepoCache; 113 if (_inGitRepoCache != null) return _inGitRepoCache;
114 114
115 if (dir == null || !git.isInstalled) { 115 if (dir == null || !git.isInstalled) {
116 _inGitRepoCache = false; 116 _inGitRepoCache = false;
117 } else { 117 } else {
118 try { 118 // If the entire package directory is ignored, don't consider it part of a
119 git.runSync(['rev-parse'], workingDir: dir); 119 // git repo. `git check-ignore` will return a status code of 0 for
120 _inGitRepoCache = true; 120 // ignored, 1 for not ignored, and 128 for not a Git repo.
121 } on git.GitException catch (_) { 121 var result = runProcessSync(git.command, ['check-ignore', '--quiet', '.'],
122 _inGitRepoCache = false; 122 workingDir: dir);
123 } 123 _inGitRepoCache = result.exitCode == 1;
Bob Nystrom 2015/08/26 23:19:02 Instead of making git.command public, how about mo
nweiz 2015/08/27 19:04:33 I'll do this if you want, but I think a lot of the
124 } 124 }
125 125
126 return _inGitRepoCache; 126 return _inGitRepoCache;
127 } 127 }
128 bool _inGitRepoCache; 128 bool _inGitRepoCache;
129 129
130 /// Loads the package whose root directory is [packageDir]. 130 /// Loads the package whose root directory is [packageDir].
131 /// 131 ///
132 /// [name] is the expected name of that package (e.g. the name given in the 132 /// [name] is the expected name of that package (e.g. the name given in the
133 /// dependency), or `null` if the package being loaded is the entrypoint 133 /// dependency), or `null` if the package being loaded is the entrypoint
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 435
436 bool operator ==(other) { 436 bool operator ==(other) {
437 // TODO(rnystrom): We're assuming here that we don't need to delve into the 437 // TODO(rnystrom): We're assuming here that we don't need to delve into the
438 // description. 438 // description.
439 return other is PackageDep && 439 return other is PackageDep &&
440 other.name == name && 440 other.name == name &&
441 other.source == source && 441 other.source == source &&
442 other.constraint == constraint; 442 other.constraint == constraint;
443 } 443 }
444 } 444 }
OLDNEW
« no previous file with comments | « lib/src/git.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698