[tools] make rev_sdk_deps.dart work with packaged references
third_party/pkg/protobuf (and possibly others) uses a compressed reference file (.git/packed-refs) rather than the .git/refs/heads/(master|main) file expected by rev_sdk_deps.dart. modify rev_sdk_deps.dart to use "git show-ref --verify refs/remotes/origin/main" instead. TEST: I ran the script and it produced the expected commit hashes for both a package that uses a "main" default branch and a "master" default branch. Change-Id: Ibe2ec2cf368d859ca78d1873f287722eb73e481b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488262 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Brian Quinlan <bquinlan@google.com>
This commit is contained in:
committed by
Commit Queue
parent
9e015ed1ed
commit
c7e58f832a
+9
-12
@@ -201,19 +201,16 @@ class GitHelper {
|
||||
}
|
||||
|
||||
String get defaultBranchName {
|
||||
var branchNames = Directory(path.join(dir, '.git', 'refs', 'heads'))
|
||||
.listSync()
|
||||
.whereType<File>()
|
||||
.map((f) => path.basename(f.path))
|
||||
.toSet();
|
||||
|
||||
for (var name in ['main', 'master']) {
|
||||
if (branchNames.contains(name)) {
|
||||
return name;
|
||||
}
|
||||
if (Process.runSync(
|
||||
'git',
|
||||
['show-ref', '--verify', '--quiet', 'refs/remotes/origin/main'],
|
||||
workingDirectory: dir,
|
||||
).exitCode ==
|
||||
0) {
|
||||
return 'main';
|
||||
} else {
|
||||
return 'master';
|
||||
}
|
||||
|
||||
return 'main';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user