Skip to content
Snippets Groups Projects
Commit ac9be18a authored by rnystrom@google.com's avatar rnystrom@google.com Committed by Natalie Weizenbaum
Browse files

Don't use .gitignore when determining what to build/serve/run.

(Still use it for publishing.)

BUG=https://code.google.com/p/dart/issues/detail?id=9841
R=nweiz@google.com

Review URL: https://codereview.chromium.org//599303002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@40661 260f80e4-7a28-3924-810f-c04153c831b5
parent f88ec5ca
No related branches found
No related tags found
No related merge requests found
......@@ -117,7 +117,7 @@ class LishCommand extends PubCommand {
'pubspec.');
}
var files = entrypoint.root.listFiles();
var files = entrypoint.root.listFiles(useGitIgnore: true);
log.fine('Archiving and publishing ${entrypoint.root}.');
// Show the package contents so the user can verify they look OK.
......
......@@ -183,9 +183,13 @@ class Package {
/// [recursive] is true, this will return all files beneath that path;
/// otherwise, it will only return files one level beneath it.
///
/// If [useGitIgnore] is passed, this will take the .gitignore rules into
/// account if the package's root directory is a Git repository.
///
/// Note that the returned paths won't always be beneath [dir]. To safely
/// convert them to paths relative to the package root, use [relative].
List<String> listFiles({String beneath, recursive: true}) {
List<String> listFiles({String beneath, bool recursive: true,
bool useGitIgnore: false}) {
if (beneath == null) {
beneath = dir;
} else {
......@@ -200,7 +204,7 @@ class Package {
// path package, since re-parsing a path is very expensive relative to
// string operations.
var files;
if (git.isInstalled && dirExists(path('.git'))) {
if (useGitIgnore && git.isInstalled && dirExists(path('.git'))) {
// 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);
......
......@@ -20,7 +20,7 @@ class CompiledDartdocValidator extends Validator {
Future validate() {
return new Future.sync(() {
for (var entry in entrypoint.root.listFiles()) {
for (var entry in entrypoint.root.listFiles(useGitIgnore: true)) {
if (path.basename(entry) != "nav.json") continue;
var dir = path.dirname(entry);
......
......@@ -13,8 +13,8 @@ import '../lib/src/system_cache.dart';
import 'descriptor.dart' as d;
import 'test_pub.dart';
var root;
var entrypoint;
String root;
Entrypoint entrypoint;
main() {
initConfig();
......@@ -78,7 +78,7 @@ main() {
});
});
integration("ignores files that are gitignored", () {
integration("ignores files that are gitignored if desired", () {
d.dir(appPath, [
d.file('.gitignore', '*.txt'),
d.file('file1.txt', 'contents'),
......@@ -90,13 +90,23 @@ main() {
]).create();
schedule(() {
expect(entrypoint.root.listFiles(), unorderedEquals([
expect(entrypoint.root.listFiles(useGitIgnore: true), unorderedEquals([
path.join(root, 'pubspec.yaml'),
path.join(root, '.gitignore'),
path.join(root, 'file2.text'),
path.join(root, 'subdir', 'subfile2.text')
]));
});
schedule(() {
expect(entrypoint.root.listFiles(), unorderedEquals([
path.join(root, 'pubspec.yaml'),
path.join(root, 'file1.txt'),
path.join(root, 'file2.text'),
path.join(root, 'subdir', 'subfile1.txt'),
path.join(root, 'subdir', 'subfile2.text')
]));
});
});
commonTests();
......
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library pub_tests;
import '../descriptor.dart' as d;
import '../test_pub.dart';
import 'utils.dart';
main() {
initConfig();
integration("doesn't serve .gitignored assets in a path dependency", () {
ensureGit();
d.dir(appPath, [
d.appPubspec({"foo": {"path": "../foo"}}),
]).create();
d.git("foo", [
d.libPubspec("foo", "1.0.0"),
d.dir("lib", [
d.file("outer.txt", "outer contents"),
d.file("visible.txt", "visible"),
d.dir("dir", [
d.file("inner.txt", "inner contents"),
])
]),
d.file(".gitignore", "/lib/outer.txt\n/lib/dir")
]).create();
pubServe(shouldGetFirst: true);
requestShould404("packages/foo/outer.txt");
requestShould404("packages/foo/dir/inner.txt");
requestShouldSucceed("packages/foo/visible.txt", "visible");
endPubServe();
});
}
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library pub_tests;
import '../descriptor.dart' as d;
import '../test_pub.dart';
import 'utils.dart';
main() {
initConfig();
integration("doesn't serve .gitignored assets", () {
ensureGit();
d.git(appPath, [
d.appPubspec(),
d.dir("web", [
d.file("outer.txt", "outer contents"),
d.dir("dir", [
d.file("inner.txt", "inner contents"),
])
]),
d.file(".gitignore", "/web/outer.txt\n/web/dir")
]).create();
pubServe();
requestShould404("outer.txt");
requestShould404("dir/inner.txt");
endPubServe();
});
}
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library pub_tests;
import '../descriptor.dart' as d;
import '../test_pub.dart';
import 'utils.dart';
main() {
initConfig();
integration("serves hidden assets that aren't .gitignored", () {
ensureGit();
d.git(appPath, [
d.appPubspec(),
d.dir("web", [
d.file(".outer.txt", "outer contents"),
d.dir(".dir", [
d.file("inner.txt", "inner contents"),
])
])
]).create();
pubServe();
requestShouldSucceed(".outer.txt", "outer contents");
requestShouldSucceed(".dir/inner.txt", "inner contents");
endPubServe();
});
}
......@@ -102,4 +102,4 @@ main() {
expectValidationWarning(compiledDartdoc);
});
});
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment