[flutter_tools] Fix VersionUpstreamValidator to respect FLUTTER_GIT_URL (#100605)
This commit is contained in:
parent
71ec251a59
commit
e7ab846d14
@ -449,15 +449,16 @@ class VersionUpstreamValidator {
|
||||
|
||||
// Strip `.git` suffix before comparing the remotes
|
||||
final List<String> sanitizedStandardRemotes = <String>[
|
||||
if (flutterGit != null) flutterGit,
|
||||
'https://github.com/flutter/flutter.git',
|
||||
'git@github.com:flutter/flutter.git',
|
||||
// If `FLUTTER_GIT_URL` is set, use that as standard remote.
|
||||
if (flutterGit != null) flutterGit
|
||||
// Else use the predefined standard remotes.
|
||||
else ..._standardRemotes,
|
||||
].map((String remote) => stripDotGit(remote)).toList();
|
||||
|
||||
final String sanitizedRepositoryUrl = stripDotGit(repositoryUrl);
|
||||
|
||||
if (!sanitizedStandardRemotes.contains(sanitizedRepositoryUrl)) {
|
||||
if (platform.environment.containsKey('FLUTTER_GIT_URL')) {
|
||||
if (flutterGit != null) {
|
||||
// If `FLUTTER_GIT_URL` is set, inform to either remove the
|
||||
// `FLUTTER_GIT_URL` environment variable or set it to the current
|
||||
// tracking remote.
|
||||
@ -482,6 +483,12 @@ class VersionUpstreamValidator {
|
||||
return null;
|
||||
}
|
||||
|
||||
// The predefined list of remotes that are considered to be standard.
|
||||
static final List<String> _standardRemotes = <String>[
|
||||
'https://github.com/flutter/flutter.git',
|
||||
'git@github.com:flutter/flutter.git',
|
||||
];
|
||||
|
||||
// Strips ".git" suffix from a given string, preferably an url.
|
||||
// For example, changes 'https://github.com/flutter/flutter.git' to 'https://github.com/flutter/flutter'.
|
||||
// URLs without ".git" suffix will remain unaffected.
|
||||
|
@ -379,17 +379,17 @@ void main() {
|
||||
), isNull);
|
||||
});
|
||||
|
||||
testWithoutContext('returns error at remote url and FLUTTER_GIT_URL set to different urls', () {
|
||||
testWithoutContext('respects FLUTTER_GIT_URL even if upstream remote url is standard', () {
|
||||
final VersionCheckError error = runUpstreamValidator(
|
||||
versionUpstreamUrl: flutterNonStandardUrlDotGit,
|
||||
flutterGitUrl: flutterStandardUrlDotGit,
|
||||
versionUpstreamUrl: flutterStandardUrlDotGit,
|
||||
flutterGitUrl: flutterNonStandardUrlDotGit,
|
||||
);
|
||||
expect(error, isNotNull);
|
||||
expect(
|
||||
error.message,
|
||||
contains(
|
||||
'The Flutter SDK is tracking "$flutterNonStandardUrlDotGit" but "FLUTTER_GIT_URL" is set to "$flutterStandardUrlDotGit".\n'
|
||||
'Either remove "FLUTTER_GIT_URL" from the environment or set it to "$flutterNonStandardUrlDotGit". '
|
||||
'The Flutter SDK is tracking "$flutterStandardUrlDotGit" but "FLUTTER_GIT_URL" is set to "$flutterNonStandardUrlDotGit".\n'
|
||||
'Either remove "FLUTTER_GIT_URL" from the environment or set it to "$flutterStandardUrlDotGit". '
|
||||
'If this is intentional, it is recommended to use "git" directly to manage the SDK.'
|
||||
),
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user