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
f6db8ccd
Unverified
Commit
f6db8ccd
authored
May 04, 2020
by
Peter Lauri
Committed by
GitHub
May 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fix version tag `v` stripping and support old "dev" and new "pre" tags (#55602)
parent
6dc1e83f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
37 deletions
+40
-37
version.dart
packages/flutter_tools/lib/src/commands/version.dart
+2
-9
version_test.dart
...tter_tools/test/commands.shard/hermetic/version_test.dart
+38
-28
No files found.
packages/flutter_tools/lib/src/commands/version.dart
View file @
f6db8ccd
...
...
@@ -13,7 +13,6 @@ import '../cache.dart';
import
'../dart/pub.dart'
;
import
'../globals.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
import
'../version.dart'
;
class
VersionCommand
extends
FlutterCommand
{
VersionCommand
()
:
super
()
{
...
...
@@ -87,7 +86,7 @@ class VersionCommand extends FlutterCommand {
}
}
final
String
version
=
argResults
.
rest
[
0
].
replaceFirst
(
'v'
,
''
);
final
String
version
=
argResults
.
rest
[
0
].
replaceFirst
(
RegExp
(
'^v'
)
,
''
);
final
List
<
String
>
matchingTags
=
tags
.
where
((
String
tag
)
=>
tag
.
contains
(
version
)).
toList
();
String
matchingTag
;
// TODO(fujino): make this a tool exit and fix tests
...
...
@@ -127,15 +126,12 @@ class VersionCommand extends FlutterCommand {
throwToolExit
(
'Unable to checkout version branch for version
$version
:
$e
'
);
}
final
FlutterVersion
flutterVersion
=
FlutterVersion
();
globals
.
printStatus
(
'Switching Flutter to version
${flutterVersion.frameworkVersion}${withForce ? ' with force' : ''}
'
);
globals
.
printStatus
(
'Switching Flutter to version
$matchingTag${withForce ? ' with force' : ''}
'
);
// Check for and download any engine and pkg/ updates.
// We run the 'flutter' shell script re-entrantly here
// so that it will download the updated Dart and so forth
// if necessary.
globals
.
printStatus
(
''
);
globals
.
printStatus
(
'Downloading engine...'
);
int
code
=
await
processUtils
.
stream
(<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'flutter'
),
...
...
@@ -147,9 +143,6 @@ class VersionCommand extends FlutterCommand {
throwToolExit
(
null
,
exitCode:
code
);
}
globals
.
printStatus
(
''
);
globals
.
printStatus
(
flutterVersion
.
toString
());
final
String
projectRoot
=
findProjectRoot
();
if
(
projectRoot
!=
null
&&
boolArg
(
'pub'
))
{
globals
.
printStatus
(
''
);
...
...
packages/flutter_tools/test/commands.shard/hermetic/version_test.dart
View file @
f6db8ccd
...
...
@@ -42,7 +42,7 @@ void main() {
'version'
,
'--no-pub'
,
]);
expect
(
testLogger
.
statusText
,
equals
(
'v10.0.0
\r\n
v20.0.0
\r\n
30.0.0-dev.0.0
\n
'
));
expect
(
testLogger
.
statusText
,
equals
(
'v10.0.0
\r\n
v20.0.0
\r\n
30.0.0-dev.0.0
\
r\n
31.0.0-0.0.pre
\
n
'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Stdio:
()
=>
mockStdio
,
...
...
@@ -51,7 +51,7 @@ void main() {
testUsingContext
(
'version switch prompt is accepted'
,
()
async
{
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
const
String
version
=
'10.0.0'
;
const
String
version
=
'
v
10.0.0'
;
final
VersionCommand
command
=
VersionCommand
();
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'y'
,
'n'
],
logger:
anyNamed
(
'logger'
),
...
...
@@ -71,21 +71,21 @@ void main() {
FlutterVersion:
()
=>
mockVersion
,
});
testUsingContext
(
'
version switch prompt is declin
ed'
,
()
async
{
testUsingContext
(
'
old dev version switch prompt is accept
ed'
,
()
async
{
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
const
String
version
=
'
10
.0.0'
;
const
String
version
=
'
30.0.0-dev
.0.0'
;
final
VersionCommand
command
=
VersionCommand
();
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'y'
,
'n'
],
logger:
anyNamed
(
'logger'
),
prompt:
'Are you sure you want to proceed?'
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'
n
'
);
).
thenAnswer
((
Invocation
invocation
)
async
=>
'
y
'
);
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'version'
,
'--no-pub'
,
version
,
]);
expect
(
testLogger
.
statusText
,
isNot
(
contains
(
'Switching Flutter to version
$version
'
)
));
expect
(
testLogger
.
statusText
,
contains
(
'Switching Flutter to version
$version
'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Stdio:
()
=>
mockStdio
,
...
...
@@ -93,30 +93,47 @@ void main() {
FlutterVersion:
()
=>
mockVersion
,
});
testUsingContext
(
'version switch, latest commit query fails'
,
()
async
{
const
String
version
=
'10.0.0'
;
testUsingContext
(
'dev version switch prompt is accepted'
,
()
async
{
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
const
String
version
=
'31.0.0-0.0.pre'
;
final
VersionCommand
command
=
VersionCommand
();
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'y'
,
'n'
],
logger:
anyNamed
(
'logger'
),
prompt:
'Are you sure you want to proceed?'
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'y'
);
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'version'
,
'--no-pub'
,
version
,
]);
expect
(
testLogger
.
errorText
,
contains
(
'git failed
'
));
expect
(
testLogger
.
statusText
,
contains
(
'Switching Flutter to version
$version
'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(
latestCommitFails:
true
),
ProcessManager:
()
=>
MockProcessManager
(),
Stdio:
()
=>
mockStdio
,
AnsiTerminal:
()
=>
MockTerminal
(),
FlutterVersion:
()
=>
mockVersion
,
});
testUsingContext
(
'latest commit is parsable when query fails'
,
()
{
final
FlutterVersion
flutterVersion
=
FlutterVersion
();
expect
(
()
=>
DateTime
.
parse
(
flutterVersion
.
frameworkCommitDate
),
returnsNormally
,
);
testUsingContext
(
'version switch prompt is declined'
,
()
async
{
when
(
mockStdio
.
stdinHasTerminal
).
thenReturn
(
true
);
const
String
version
=
'10.0.0'
;
final
VersionCommand
command
=
VersionCommand
();
when
(
globals
.
terminal
.
promptForCharInput
(<
String
>[
'y'
,
'n'
],
logger:
anyNamed
(
'logger'
),
prompt:
'Are you sure you want to proceed?'
)
).
thenAnswer
((
Invocation
invocation
)
async
=>
'n'
);
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'version'
,
'--no-pub'
,
version
,
]);
expect
(
testLogger
.
statusText
,
isNot
(
contains
(
'Switching Flutter to version
$version
'
)));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(
latestCommitFails:
true
),
ProcessManager:
()
=>
MockProcessManager
(),
Stdio:
()
=>
mockStdio
,
AnsiTerminal:
()
=>
MockTerminal
(),
FlutterVersion:
()
=>
mockVersion
,
});
...
...
@@ -187,7 +204,7 @@ void main() {
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'version'
,
]);
expect
(
testLogger
.
statusText
,
equals
(
'v10.0.0
\r\n
v20.0.0
\r\n
30.0.0-dev.0.0
\n
'
));
expect
(
testLogger
.
statusText
,
equals
(
'v10.0.0
\r\n
v20.0.0
\r\n
30.0.0-dev.0.0
\
r\n
31.0.0-0.0.pre
\
n
'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Stdio:
()
=>
mockStdio
,
...
...
@@ -236,11 +253,12 @@ class MockProcessManager extends Mock implements ProcessManager {
if
(
failGitTag
)
{
return
ProcessResult
(
0
,
1
,
''
,
''
);
}
return
ProcessResult
(
0
,
0
,
'v10.0.0
\r\n
v20.0.0
\r\n
30.0.0-dev.0.0'
,
''
);
return
ProcessResult
(
0
,
0
,
'v10.0.0
\r\n
v20.0.0
\r\n
30.0.0-dev.0.0
\r\n
31.0.0-0.0.pre
'
,
''
);
}
if
(
command
[
0
]
==
'git'
&&
command
[
1
]
==
'checkout'
)
{
version
=
(
command
[
2
]
as
String
).
replaceFirst
(
'v'
,
''
);
version
=
(
command
[
2
]
as
String
).
replaceFirst
(
RegExp
(
'^v'
)
,
''
);
}
return
ProcessResult
(
0
,
0
,
''
,
''
);
}
...
...
@@ -264,14 +282,6 @@ class MockProcessManager extends Mock implements ProcessManager {
return
ProcessResult
(
0
,
0
,
'
$version
-0-g00000000'
,
''
);
}
}
final
List
<
String
>
commitDateCommand
=
<
String
>[
'-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
,
];
if
(
latestCommitFails
&&
commandStr
==
FlutterVersion
.
gitLog
(
commitDateCommand
).
join
(
' '
))
{
return
ProcessResult
(
0
,
-
9
,
''
,
'git failed'
);
}
return
ProcessResult
(
0
,
0
,
''
,
''
);
}
...
...
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