Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
52ea6c2a
Unverified
Commit
52ea6c2a
authored
Dec 09, 2020
by
Zachary Anderson
Committed by
GitHub
Dec 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Fix crash in update-packages (#71950)
parent
a56e616c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
update_packages.dart
packages/flutter_tools/lib/src/commands/update_packages.dart
+14
-1
update_packages_test.dart
...lutter_tools/test/general.shard/update_packages_test.dart
+29
-0
No files found.
packages/flutter_tools/lib/src/commands/update_packages.dart
View file @
52ea6c2a
...
...
@@ -320,6 +320,7 @@ class UpdatePackagesCommand extends FlutterCommand {
Directory
temporaryFlutterSdk
;
if
(
upgrade
)
{
temporaryFlutterSdk
=
createTemporaryFlutterSdk
(
globals
.
logger
,
globals
.
fs
,
globals
.
fs
.
directory
(
Cache
.
flutterRoot
),
pubspecs
,
...
...
@@ -1417,7 +1418,13 @@ String _computeChecksum(Iterable<String> names, String getVersion(String name))
/// Create a synthetic Flutter SDK so that pub version solving does not get
/// stuck on the old versions.
Directory
createTemporaryFlutterSdk
(
FileSystem
fileSystem
,
Directory
realFlutter
,
List
<
PubspecYaml
>
pubspecs
)
{
@visibleForTesting
Directory
createTemporaryFlutterSdk
(
Logger
logger
,
FileSystem
fileSystem
,
Directory
realFlutter
,
List
<
PubspecYaml
>
pubspecs
,
)
{
final
Set
<
String
>
currentPackages
=
realFlutter
.
childDirectory
(
'packages'
)
.
listSync
()
...
...
@@ -1445,6 +1452,12 @@ Directory createTemporaryFlutterSdk(FileSystem fileSystem, Directory realFlutter
.
childFile
(
'pubspec.yaml'
)
..
createSync
(
recursive:
true
);
final
PubspecYaml
pubspecYaml
=
pubspecsByName
[
flutterPackage
];
if
(
pubspecYaml
==
null
)
{
logger
.
printError
(
"Unexpected package '
$flutterPackage
' found in packages directory"
,
);
continue
;
}
final
StringBuffer
output
=
StringBuffer
(
'name:
$flutterPackage
\n
'
);
// Fill in SDK dependency constraint.
...
...
packages/flutter_tools/test/general.shard/update_packages_test.dart
View file @
52ea6c2a
...
...
@@ -5,6 +5,7 @@
import
'package:file/memory.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/commands/update_packages.dart'
;
import
'../src/common.dart'
;
...
...
@@ -47,6 +48,17 @@ dev_dependencies:
# PUBSPEC CHECKSUM: 1437
'''
;
const
String
kExtraPubspecYaml
=
r''
'
name: nodeps
author: Flutter Authors <flutter-dev@googlegroups.com>
description: A dummy pubspec with no dependencies
homepage: http://flutter.dev
environment:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk: ">=2.2.2 <3.0.0"
'''
;
const
String
kInvalidGitPubspec
=
'''
name: flutter
author: Flutter Authors <flutter-dev@googlegroups.com>
...
...
@@ -89,6 +101,15 @@ void main() {
.
childFile
(
'pubspec.yaml'
)
.
writeAsStringSync
(
kFlutterPubspecYaml
);
// A stray extra package should not cause a crash.
final
Directory
extra
=
flutterSdk
.
childDirectory
(
'packages'
)
.
childDirectory
(
'extra'
)
..
createSync
(
recursive:
true
);
extra
.
childFile
(
'pubspec.yaml'
)
.
writeAsStringSync
(
kExtraPubspecYaml
);
// Create already parsed pubspecs.
final
PubspecYaml
flutterPubspec
=
PubspecYaml
(
flutter
);
...
...
@@ -101,7 +122,9 @@ void main() {
ref: d00362e6bdd0f9b30bba337c358b9e4a6e4ca950
'''
,
);
final
BufferLogger
bufferLogger
=
BufferLogger
.
test
();
final
Directory
result
=
createTemporaryFlutterSdk
(
bufferLogger
,
fileSystem
,
flutterSdk
,
<
PubspecYaml
>[
flutterPubspec
],
...
...
@@ -109,6 +132,12 @@ void main() {
expect
(
result
,
exists
);
// We get a warning about the unexpected package.
expect
(
bufferLogger
.
errorText
,
contains
(
"Unexpected package 'extra' found in packages directory"
),
);
// The version file exists.
expect
(
result
.
childFile
(
'version'
),
exists
);
expect
(
result
.
childFile
(
'version'
).
readAsStringSync
(),
'1.2.3'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment