[cfe] Normalize repo dir
Uri.base, Platform.script and dart:io operations use the drive letter capitalization of the current working directory, but git, alas, does not. This normalizes the computeRepoDir to match that of Uri.base, thus avoiding spurious errors on Windows. Change-Id: If4324874fa9b5c73c679c1b67a9481371ce8808d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421161 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
committed by
Commit Queue
parent
a2ae02e3f0
commit
e7e07f73aa
@@ -35,6 +35,20 @@ String computeRepoDir() {
|
||||
if (!new Directory(dirPath).existsSync()) {
|
||||
throw "The path returned by git ($dirPath) does not actually exist.";
|
||||
}
|
||||
if (dirPath.length > 1 && dirPath[1] == ':') {
|
||||
// Absolute Windows path. Normalize drive letter to match Uri.base.
|
||||
if (Uri.base.path.length < 3 ||
|
||||
Uri.base.path[0] != '/' ||
|
||||
Uri.base.path[2] != ':') {
|
||||
throw "Expected Uri.base=${Uri.base} to be an absolute file path.";
|
||||
}
|
||||
bool isLowerCase = Uri.base.path[1] == Uri.base.path[1].toLowerCase();
|
||||
if (isLowerCase) {
|
||||
dirPath = dirPath[0].toLowerCase() + dirPath.substring(1);
|
||||
} else {
|
||||
dirPath = dirPath[0].toUpperCase() + dirPath.substring(1);
|
||||
}
|
||||
}
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user