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
ca0596e4
Unverified
Commit
ca0596e4
authored
Feb 02, 2023
by
Sigurd Meldgaard
Committed by
GitHub
Feb 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `pub get --unknown-flag` (#119622)
parent
fd76ef0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+6
-1
pub_get_test.dart
...tter_tools/test/commands.shard/hermetic/pub_get_test.dart
+30
-0
No files found.
packages/flutter_tools/lib/src/commands/packages.dart
View file @
ca0596e4
...
@@ -213,6 +213,7 @@ class PackagesGetCommand extends FlutterCommand {
...
@@ -213,6 +213,7 @@ class PackagesGetCommand extends FlutterCommand {
argParser
.
addOption
(
'git-ref'
);
argParser
.
addOption
(
'git-ref'
);
argParser
.
addOption
(
'git-path'
);
argParser
.
addOption
(
'git-path'
);
argParser
.
addFlag
(
'dev'
);
argParser
.
addFlag
(
'dev'
);
argParser
.
addFlag
(
'verbose'
,
abbr:
'v'
);
return
argParser
;
return
argParser
;
}
}
...
@@ -238,7 +239,11 @@ class PackagesGetCommand extends FlutterCommand {
...
@@ -238,7 +239,11 @@ class PackagesGetCommand extends FlutterCommand {
FlutterProject
?
rootProject
;
FlutterProject
?
rootProject
;
if
(!
isHelp
)
{
if
(!
isHelp
)
{
if
(
directoryOption
==
null
&&
rest
.
length
==
1
&&
if
(
directoryOption
==
null
&&
rest
.
length
==
1
&&
// Anything that looks like an argument should not be interpreted as
// a directory.
!
rest
.
single
.
startsWith
(
'-'
)
&&
((
rest
.
single
.
contains
(
'/'
)
||
rest
.
single
.
contains
(
r'\'
))
||
((
rest
.
single
.
contains
(
'/'
)
||
rest
.
single
.
contains
(
r'\'
))
||
name
==
'get'
))
{
name
==
'get'
))
{
// For historical reasons, if there is one argument to the command and it contains
// For historical reasons, if there is one argument to the command and it contains
...
...
packages/flutter_tools/test/commands.shard/hermetic/pub_get_test.dart
View file @
ca0596e4
...
@@ -94,6 +94,32 @@ void main() {
...
@@ -94,6 +94,32 @@ void main() {
FileSystem:
()
=>
fileSystem
,
FileSystem:
()
=>
fileSystem
,
});
});
testUsingContext
(
"pub get doesn't treat unknown flag as directory"
,
()
async
{
fileSystem
.
currentDirectory
.
childDirectory
(
'target'
).
createSync
();
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
final
PackagesGetCommand
command
=
PackagesGetCommand
(
'get'
,
''
,
PubContext
.
pubGet
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
command
);
pub
.
expectedArguments
=
<
String
>[
'get'
,
'--unknown-flag'
,
'--example'
,
'--directory'
,
'.'
];
await
commandRunner
.
run
(<
String
>[
'get'
,
'--unknown-flag'
]);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
pub
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
FileSystem:
()
=>
fileSystem
,
});
testUsingContext
(
"pub get doesn't treat -v as directory"
,
()
async
{
fileSystem
.
currentDirectory
.
childDirectory
(
'target'
).
createSync
();
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
final
PackagesGetCommand
command
=
PackagesGetCommand
(
'get'
,
''
,
PubContext
.
pubGet
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
command
);
pub
.
expectedArguments
=
<
String
>[
'get'
,
'-v'
,
'--example'
,
'--directory'
,
'.'
];
await
commandRunner
.
run
(<
String
>[
'get'
,
'-v'
]);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
pub
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
FileSystem:
()
=>
fileSystem
,
});
testUsingContext
(
"pub get skips example directory if it doesn't contain a pubspec.yaml"
,
()
async
{
testUsingContext
(
"pub get skips example directory if it doesn't contain a pubspec.yaml"
,
()
async
{
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
currentDirectory
.
childFile
(
'pubspec.yaml'
).
createSync
();
fileSystem
.
currentDirectory
.
childDirectory
(
'example'
).
createSync
(
recursive:
true
);
fileSystem
.
currentDirectory
.
childDirectory
(
'example'
).
createSync
(
recursive:
true
);
...
@@ -181,6 +207,7 @@ class FakePub extends Fake implements Pub {
...
@@ -181,6 +207,7 @@ class FakePub extends Fake implements Pub {
FakePub
(
this
.
fileSystem
);
FakePub
(
this
.
fileSystem
);
final
FileSystem
fileSystem
;
final
FileSystem
fileSystem
;
List
<
String
>?
expectedArguments
;
@override
@override
Future
<
void
>
interactively
(
Future
<
void
>
interactively
(
...
@@ -192,6 +219,9 @@ class FakePub extends Fake implements Pub {
...
@@ -192,6 +219,9 @@ class FakePub extends Fake implements Pub {
bool
generateSyntheticPackage
=
false
,
bool
generateSyntheticPackage
=
false
,
PubOutputMode
outputMode
=
PubOutputMode
.
all
,
PubOutputMode
outputMode
=
PubOutputMode
.
all
,
})
async
{
})
async
{
if
(
expectedArguments
!=
null
)
{
expect
(
arguments
,
expectedArguments
);
}
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
fileSystem
.
directory
(
project
.
directory
)
fileSystem
.
directory
(
project
.
directory
)
.
childDirectory
(
'.dart_tool'
)
.
childDirectory
(
'.dart_tool'
)
...
...
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