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
71c42c9c
Unverified
Commit
71c42c9c
authored
Sep 24, 2020
by
includecmath
Committed by
GitHub
Sep 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Add channel order aware version_test (#62417)
parent
a2406601
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
40 deletions
+48
-40
channel.dart
packages/flutter_tools/lib/src/commands/channel.dart
+6
-6
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+1
-1
version.dart
packages/flutter_tools/lib/src/version.dart
+29
-29
channel_test.dart
packages/flutter_tools/test/general.shard/channel_test.dart
+3
-3
version_test.dart
packages/flutter_tools/test/general.shard/version_test.dart
+9
-1
No files found.
packages/flutter_tools/lib/src/commands/channel.dart
View file @
71c42c9c
...
...
@@ -72,7 +72,7 @@ class ChannelCommand extends FlutterCommand {
throwToolExit
(
'List channels failed:
$result$details
'
,
exitCode:
result
);
}
final
List
<
String
>
officialChannels
=
FlutterVersion
.
o
fficialChannels
.
toList
();
final
List
<
String
>
officialChannels
=
kO
fficialChannels
.
toList
();
final
List
<
bool
>
availableChannels
=
List
<
bool
>.
filled
(
officialChannels
.
length
,
false
);
for
(
final
String
line
in
rawOutput
)
{
...
...
@@ -116,10 +116,10 @@ class ChannelCommand extends FlutterCommand {
Future
<
void
>
_switchChannel
(
String
branchName
)
async
{
globals
.
printStatus
(
"Switching to flutter channel '
$branchName
'..."
);
if
(
FlutterVersion
.
o
bsoleteBranches
.
containsKey
(
branchName
))
{
final
String
alternative
=
FlutterVersion
.
o
bsoleteBranches
[
branchName
];
if
(
kO
bsoleteBranches
.
containsKey
(
branchName
))
{
final
String
alternative
=
kO
bsoleteBranches
[
branchName
];
globals
.
printStatus
(
"This channel is obsolete. Consider switching to the '
$alternative
' channel instead."
);
}
else
if
(!
FlutterVersion
.
o
fficialChannels
.
contains
(
branchName
))
{
}
else
if
(!
kO
fficialChannels
.
contains
(
branchName
))
{
globals
.
printStatus
(
'This is not an official channel. For a list of available channels, try "flutter channel".'
);
}
await
_checkout
(
branchName
);
...
...
@@ -129,8 +129,8 @@ class ChannelCommand extends FlutterCommand {
static
Future
<
void
>
upgradeChannel
()
async
{
final
String
channel
=
globals
.
flutterVersion
.
channel
;
if
(
FlutterVersion
.
o
bsoleteBranches
.
containsKey
(
channel
))
{
final
String
alternative
=
FlutterVersion
.
o
bsoleteBranches
[
channel
];
if
(
kO
bsoleteBranches
.
containsKey
(
channel
))
{
final
String
alternative
=
kO
bsoleteBranches
[
channel
];
globals
.
printStatus
(
"Transitioning from '
$channel
' to '
$alternative
'..."
);
return
_checkout
(
alternative
);
}
...
...
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
71c42c9c
...
...
@@ -107,7 +107,7 @@ class UpgradeCommandRunner {
if
(!
force
&&
gitTagVersion
==
const
GitTagVersion
.
unknown
())
{
// If the commit is a recognized branch and not master,
// explain that we are avoiding potential damage.
if
(
flutterVersion
.
channel
!=
'master'
&&
FlutterVersion
.
o
fficialChannels
.
contains
(
flutterVersion
.
channel
))
{
if
(
flutterVersion
.
channel
!=
'master'
&&
kO
fficialChannels
.
contains
(
flutterVersion
.
channel
))
{
throwToolExit
(
'Unknown flutter tag. Abandoning upgrade to avoid destroying local '
'changes. It is recommended to use git directly if not working on '
...
...
packages/flutter_tools/lib/src/version.dart
View file @
71c42c9c
...
...
@@ -13,6 +13,20 @@ import 'cache.dart';
import
'convert.dart'
;
import
'globals.dart'
as
globals
;
/// The flutter GitHub repository.
String
get
_flutterGit
=>
globals
.
platform
.
environment
[
'FLUTTER_GIT_URL'
]
??
'https://github.com/flutter/flutter.git'
;
/// This maps old branch names to the names of branches that replaced them.
///
/// For example, in early 2018 we changed from having an "alpha" branch to
/// having a "dev" branch, so anyone using "alpha" now gets transitioned to
/// "dev".
const
Map
<
String
,
String
>
kObsoleteBranches
=
<
String
,
String
>{
'alpha'
:
'dev'
,
'hackathon'
:
'dev'
,
'codelab'
:
'dev'
,
};
/// The names of each channel/branch in order of increasing stability.
enum
Channel
{
master
,
...
...
@@ -21,23 +35,28 @@ enum Channel {
stable
,
}
/// The flutter GitHub repository.
String
get
_flutterGit
=>
globals
.
platform
.
environment
[
'FLUTTER_GIT_URL'
]
??
'https://github.com/flutter/flutter.git'
;
// Beware: Keep order in accordance with stability
const
Set
<
String
>
kOfficialChannels
=
<
String
>{
'master'
,
'dev'
,
'beta'
,
'stable'
,
};
/// Retrieve a human-readable name for a given [channel].
///
/// Requires [
FlutterVersion.o
fficialChannels] to be correctly ordered.
/// Requires [
kO
fficialChannels] to be correctly ordered.
String
getNameForChannel
(
Channel
channel
)
{
return
FlutterVersion
.
o
fficialChannels
.
elementAt
(
channel
.
index
);
return
kO
fficialChannels
.
elementAt
(
channel
.
index
);
}
/// Retrieve the [Channel] representation for a string [name].
///
/// Returns `null` if [name] is not in the list of official channels, according
/// to [
FlutterVersion.o
fficialChannels].
/// to [
kO
fficialChannels].
Channel
getChannelForName
(
String
name
)
{
if
(
FlutterVersion
.
o
fficialChannels
.
contains
(
name
))
{
return
Channel
.
values
[
FlutterVersion
.
o
fficialChannels
.
toList
().
indexOf
(
name
)];
if
(
kO
fficialChannels
.
contains
(
name
))
{
return
Channel
.
values
[
kO
fficialChannels
.
toList
().
indexOf
(
name
)];
}
return
null
;
}
...
...
@@ -84,25 +103,6 @@ class FlutterVersion {
return
!<
String
>[
'dev'
,
'beta'
,
'stable'
].
contains
(
branchName
);
}
// Beware: Keep order in accordance with stability
static
const
Set
<
String
>
officialChannels
=
<
String
>{
'master'
,
'dev'
,
'beta'
,
'stable'
,
};
/// This maps old branch names to the names of branches that replaced them.
///
/// For example, in early 2018 we changed from having an "alpha" branch to
/// having a "dev" branch, so anyone using "alpha" now gets transitioned to
/// "dev".
static
Map
<
String
,
String
>
obsoleteBranches
=
<
String
,
String
>{
'alpha'
:
'dev'
,
'hackathon'
:
'dev'
,
'codelab'
:
'dev'
,
};
String
_channel
;
/// The channel is the upstream branch.
/// `master`, `dev`, `beta`, `stable`; or old ones, like `alpha`, `hackathon`, ...
...
...
@@ -298,8 +298,8 @@ class FlutterVersion {
}();
if
(
redactUnknownBranches
||
_branch
.
isEmpty
)
{
// Only return the branch names we know about; arbitrary branch names might contain PII.
if
(!
o
fficialChannels
.
contains
(
_branch
)
&&
!
o
bsoleteBranches
.
containsKey
(
_branch
))
{
if
(!
kO
fficialChannels
.
contains
(
_branch
)
&&
!
kO
bsoleteBranches
.
containsKey
(
_branch
))
{
return
'[user-branch]'
;
}
}
...
...
@@ -388,7 +388,7 @@ class FlutterVersion {
/// writes shared cache files.
Future
<
void
>
checkFlutterVersionFreshness
()
async
{
// Don't perform update checks if we're not on an official channel.
if
(!
o
fficialChannels
.
contains
(
channel
))
{
if
(!
kO
fficialChannels
.
contains
(
channel
))
{
return
;
}
...
...
packages/flutter_tools/test/general.shard/channel_test.dart
View file @
71c42c9c
...
...
@@ -86,7 +86,7 @@ void main() {
final
Iterable
<
String
>
rows
=
testLogger
.
statusText
.
split
(
'
\n
'
)
.
map
((
String
line
)
=>
line
.
substring
(
2
));
// remove '* ' or ' ' from output
expect
(
rows
,
containsAllInOrder
(
FlutterVersion
.
o
fficialChannels
));
expect
(
rows
,
containsAllInOrder
(
kO
fficialChannels
));
// clear buffer for next process
testLogger
.
clear
();
...
...
@@ -107,7 +107,7 @@ void main() {
final
Iterable
<
String
>
rows2
=
testLogger
.
statusText
.
split
(
'
\n
'
)
.
map
((
String
line
)
=>
line
.
substring
(
2
));
// remove '* ' or ' ' from output
expect
(
rows2
,
containsAllInOrder
(
FlutterVersion
.
o
fficialChannels
));
expect
(
rows2
,
containsAllInOrder
(
kO
fficialChannels
));
// clear buffer for next process
testLogger
.
clear
();
...
...
@@ -127,7 +127,7 @@ void main() {
// check if available official channels are in order of stability
int
prev
=
-
1
;
int
next
=
-
1
;
for
(
final
String
branch
in
FlutterVersion
.
o
fficialChannels
)
{
for
(
final
String
branch
in
kO
fficialChannels
)
{
next
=
testLogger
.
statusText
.
indexOf
(
branch
);
if
(
next
!=
-
1
)
{
expect
(
prev
<
next
,
isTrue
);
...
...
packages/flutter_tools/test/general.shard/version_test.dart
View file @
71c42c9c
...
...
@@ -36,7 +36,15 @@ void main() {
mockCache
=
MockCache
();
});
for
(
final
String
channel
in
FlutterVersion
.
officialChannels
)
{
testUsingContext
(
'Channel enum and string transform to each other'
,
()
{
for
(
final
Channel
channel
in
Channel
.
values
)
{
expect
(
getNameForChannel
(
channel
),
kOfficialChannels
.
toList
()[
channel
.
index
]);
}
expect
(
kOfficialChannels
.
toList
().
map
((
String
str
)
=>
getChannelForName
(
str
)).
toList
(),
Channel
.
values
);
});
for
(
final
String
channel
in
kOfficialChannels
)
{
DateTime
getChannelUpToDateVersion
()
{
return
_testClock
.
ago
(
FlutterVersion
.
versionAgeConsideredUpToDate
(
channel
)
~/
2
);
}
...
...
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