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
2bb361c9
Unverified
Commit
2bb361c9
authored
Apr 16, 2020
by
Christopher Fujino
Committed by
GitHub
Apr 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Fix roll dev script, add tests (#54783)
parent
baafc668
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
7 deletions
+71
-7
roll_dev.dart
dev/tools/lib/roll_dev.dart
+17
-7
roll_dev_test.dart
dev/tools/test/roll_dev_test.dart
+54
-0
No files found.
dev/tools/lib/roll_dev.dart
View file @
2bb361c9
...
...
@@ -25,6 +25,7 @@ const String kUpstreamRemote = 'git@github.com:flutter/flutter.git';
void
main
(
List
<
String
>
args
)
{
final
ArgParser
argParser
=
ArgParser
(
allowTrailingOptions:
false
);
argParser
.
addOption
(
kIncrement
,
help:
'Specifies which part of the x.y.z version number to increment. Required.'
,
...
...
@@ -38,9 +39,9 @@ void main(List<String> args) {
);
argParser
.
addOption
(
kCommit
,
help:
'Specifies which git commit to roll to the dev branch.'
,
help:
'Specifies which git commit to roll to the dev branch.
Required.
'
,
valueHelp:
'hash'
,
defaultsTo:
'upstream/master'
,
defaultsTo:
null
,
// This option is required
);
argParser
.
addOption
(
kOrigin
,
...
...
@@ -57,6 +58,7 @@ void main(List<String> args) {
);
argParser
.
addFlag
(
kYes
,
negatable:
false
,
abbr:
'y'
,
help:
'Skip the confirmation prompt.'
);
argParser
.
addFlag
(
kHelp
,
negatable:
false
,
help:
'Show this help message.'
,
hide:
true
);
ArgResults
argResults
;
try
{
argResults
=
argParser
.
parse
(
args
);
...
...
@@ -73,7 +75,7 @@ void main(List<String> args) {
final
bool
autoApprove
=
argResults
[
kYes
]
as
bool
;
final
bool
help
=
argResults
[
kHelp
]
as
bool
;
if
(
help
||
level
==
null
)
{
if
(
help
||
level
==
null
||
commit
==
null
)
{
print
(
'roll_dev.dart --increment=level --commit=hash • update the version tags and roll a new dev build.
\n
'
);
print
(
argParser
.
usage
);
exit
(
0
);
...
...
@@ -165,23 +167,31 @@ void main(List<String> args) {
}
String
getFullTag
(
)
{
const
String
glob
=
'*.*.*-*.*.pre'
;
return
getGitOutput
(
'describe --match
*.*.*-dev.*.*
--first-parent --long --tags'
,
'describe --match
$glob
--first-parent --long --tags'
,
'obtain last released version number'
,
);
}
Match
parseFullTag
(
String
version
)
{
final
RegExp
versionPattern
=
RegExp
(
r'^([0-9]+)\.([0-9]+)\.([0-9]+)-dev\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)$'
);
// of the form: x.y.z-m.n.pre-c-g<revision>
final
RegExp
versionPattern
=
RegExp
(
r'^(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)\.pre-(\d+)-g([a-f0-9]+)$'
);
return
versionPattern
.
matchAsPrefix
(
version
);
}
String
getVersionFromParts
(
List
<
int
>
parts
)
{
// where parts correspond to [x, y, z, m, n] from tag
assert
(
parts
.
length
==
5
);
final
StringBuffer
buf
=
StringBuffer
()
// take x, y, and z
..
write
(
parts
.
take
(
3
).
join
(
'.'
))
..
write
(
'-dev.'
)
..
write
(
parts
.
skip
(
3
).
join
(
'.'
));
..
write
(
'-'
)
// skip x, y, and z, take m and n
..
write
(
parts
.
skip
(
3
).
take
(
2
).
join
(
'.'
))
..
write
(
'.pre'
);
// return a string that looks like: '1.2.3-4.5.pre'
return
buf
.
toString
();
}
...
...
dev/tools/test/roll_dev_test.dart
0 → 100644
View file @
2bb361c9
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:dev_tools/roll_dev.dart'
;
import
'./common.dart'
;
void
main
(
)
{
group
(
'parseFullTag'
,
()
{
test
(
'returns match on valid version input'
,
()
{
final
List
<
String
>
validTags
=
<
String
>[
'1.2.3-1.2.pre-3-gabc123'
,
'10.2.30-12.22.pre-45-gabc123'
,
'1.18.0-0.0.pre-0-gf0adb240a'
,
'2.0.0-1.99.pre-45-gf0adb240a'
,
'12.34.56-78.90.pre-12-g9db2703a2'
,
'0.0.1-0.0.pre-1-g07601eb95ff82f01e870566586340ed2e87b9cbb'
,
'958.80.144-6.224.pre-7803-g06e90'
,
];
for
(
final
String
validTag
in
validTags
)
{
final
Match
match
=
parseFullTag
(
validTag
);
expect
(
match
,
isNotNull
,
reason:
'Expected
$validTag
to be parsed'
);
}
});
test
(
'returns null on invalid version input'
,
()
{
final
List
<
String
>
invalidTags
=
<
String
>[
'1.2.3-dev.1.2-3-gabc123'
,
'1.2.3-1.2-3-gabc123'
,
'v1.2.3'
,
'2.0.0'
,
'v1.2.3-1.2.pre-3-gabc123'
,
'10.0.1-0.0.pre-gf0adb240a'
,
'10.0.1-0.0.pre-3-gggggggggg'
,
'1.2.3-1.2.pre-3-abc123'
,
'1.2.3-1.2.pre-3-gabc123_'
,
];
for
(
final
String
invalidTag
in
invalidTags
)
{
final
Match
match
=
parseFullTag
(
invalidTag
);
expect
(
match
,
null
,
reason:
'Expected
$invalidTag
to not be parsed'
);
}
});
});
group
(
'getVersionFromParts'
,
()
{
test
(
'returns correct string from valid parts'
,
()
{
List
<
int
>
parts
=
<
int
>[
1
,
2
,
3
,
4
,
5
];
expect
(
getVersionFromParts
(
parts
),
'1.2.3-4.5.pre'
);
parts
=
<
int
>[
11
,
2
,
33
,
1
,
0
];
expect
(
getVersionFromParts
(
parts
),
'11.2.33-1.0.pre'
);
});
});
}
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