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

Unified Diff: utils/pub/io.dart

Issue 11364141: Pass absolute path to git. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up some merge bugs. Created 8 years, 1 month 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 | « utils/pub/git_source.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index cccedfc17b93098bafde5f6847aaa8d9023ba6a5..e89bf956f90a71bfa2c60e462eb455a32871107e 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -19,7 +19,7 @@ bool _isGitInstalledCache;
String _gitCommandCache;
/** Gets the current working directory. */
-String get workingDir => new File('.').fullPathSync();
+String get currentWorkingDir => new File('.').fullPathSync();
const Pattern NEWLINE_PATTERN = const RegExp("\r\n?|\n\r?");
@@ -373,12 +373,26 @@ Future<File> createPackageSymlink(String name, from, to,
});
}
-/**
- * Given [entry] which may be a [String], [File], or [Directory] relative to
- * the current working directory, returns its full canonicalized path.
- */
-// TODO(rnystrom): Should this be async?
-String getFullPath(entry) => new File(_getPath(entry)).fullPathSync();
+/// Given [entry] which may be a [String], [File], or [Directory] relative to
+/// the current working directory, returns its full canonicalized path.
+String getFullPath(entry) {
+ var path = _getPath(entry);
+
+ // Don't do anything if it's already absolute.
+ if (Platform.operatingSystem == 'windows') {
+ // An absolute path on Windows is either UNC (two leading backslashes),
+ // or a drive letter followed by a colon and a slash.
+ const ABSOLUTE = const RegExp(r'^(\\\\|[a-zA-Z]:[/\\])');
+ if (ABSOLUTE.hasMatch(path)) return path;
+ } else {
+ if (path.startsWith('/')) return path;
+ }
+
+ // Using Path.join here instead of File().fullPathSync() because the former
+ // does not require an actual file to exist at that path.
+ return new Path.fromNative(currentWorkingDir).join(new Path(path))
+ .toNativePath();
+}
// TODO(nweiz): make this configurable
/**
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698