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
a07c9a12
Commit
a07c9a12
authored
Mar 09, 2019
by
Ian Hickson
Committed by
Jonah Williams
Mar 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support hotfix version numbers (#28672)
parent
024eaa3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
7 deletions
+41
-7
version.dart
packages/flutter_tools/lib/src/version.dart
+19
-7
version_test.dart
packages/flutter_tools/test/version_test.dart
+22
-0
No files found.
packages/flutter_tools/lib/src/version.dart
View file @
a07c9a12
...
...
@@ -539,11 +539,12 @@ String _shortGitRevision(String revision) {
}
class
GitTagVersion
{
const
GitTagVersion
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
commits
,
this
.
hash
);
const
GitTagVersion
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
hotfix
,
this
.
commits
,
this
.
hash
);
const
GitTagVersion
.
unknown
()
:
x
=
null
,
y
=
null
,
z
=
null
,
hotfix
=
null
,
commits
=
0
,
hash
=
''
;
...
...
@@ -556,6 +557,9 @@ class GitTagVersion {
/// The Z in vX.Y.Z.
final
int
z
;
/// the F in vX.Y.Z-hotfix.F
final
int
hotfix
;
/// Number of commits since the vX.Y.Z tag.
final
int
commits
;
...
...
@@ -563,22 +567,30 @@ class GitTagVersion {
final
String
hash
;
static
GitTagVersion
determine
()
{
final
String
version
=
_runGit
(
'git describe --match v*.*.* --first-parent --long --tags'
);
final
RegExp
versionPattern
=
RegExp
(
'^v([0-9]+)
\
.([0-9]+)
\
.([0-9]+)-([0-9]+)-g([a-f0-9]+)
\$
'
);
final
List
<
String
>
parts
=
versionPattern
.
matchAsPrefix
(
version
)?.
groups
(<
int
>[
1
,
2
,
3
,
4
,
5
]);
return
parse
(
_runGit
(
'git describe --match v*.*.* --first-parent --long --tags'
));
}
static
GitTagVersion
parse
(
String
version
)
{
final
RegExp
versionPattern
=
RegExp
(
r'^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-hotfix\.([0-9]+))?-([0-9]+)-g([a-f0-9]+)$'
);
final
List
<
String
>
parts
=
versionPattern
.
matchAsPrefix
(
version
)?.
groups
(<
int
>[
1
,
2
,
3
,
4
,
5
,
6
]);
if
(
parts
==
null
)
{
printTrace
(
'Could not interpret results of "git describe":
$version
'
);
return
const
GitTagVersion
.
unknown
();
}
final
List
<
int
>
parsedParts
=
parts
.
take
(
4
).
map
<
int
>(
int
.
tryParse
).
toList
();
return
GitTagVersion
(
parsedParts
[
0
],
parsedParts
[
1
],
parsedParts
[
2
],
parsedParts
[
3
],
par
ts
[
4
]);
final
List
<
int
>
parsedParts
=
parts
.
take
(
5
).
map
<
int
>((
String
source
)
=>
source
==
null
?
null
:
int
.
tryParse
(
source
)
).
toList
();
return
GitTagVersion
(
parsedParts
[
0
],
parsedParts
[
1
],
parsedParts
[
2
],
parsedParts
[
3
],
par
sedParts
[
4
],
parts
[
5
]);
}
String
frameworkVersionFor
(
String
revision
)
{
if
(
x
==
null
||
y
==
null
||
z
==
null
||
!
revision
.
startsWith
(
hash
))
return
'0.0.0-unknown'
;
if
(
commits
==
0
)
if
(
commits
==
0
)
{
if
(
hotfix
!=
null
)
return
'
$x
.
$y
.
$z
-hotfix.
$hotfix
'
;
return
'
$x
.
$y
.
$z
'
;
}
if
(
hotfix
!=
null
)
return
'
$x
.
$y
.
$z
-hotfix.
${hotfix + 1}
-pre.
$commits
'
;
return
'
$x
.
$y
.
${z + 1}
-pre.
$commits
'
;
}
}
...
...
packages/flutter_tools/test/version_test.dart
View file @
a07c9a12
...
...
@@ -388,6 +388,28 @@ void main() {
});
});
}
testUsingContext
(
'GitTagVersion'
,
()
{
const
String
hash
=
'abcdef'
;
expect
(
GitTagVersion
.
parse
(
'v1.2.3-4-g
$hash
'
).
frameworkVersionFor
(
hash
),
'1.2.4-pre.4'
);
expect
(
GitTagVersion
.
parse
(
'v98.76.54-32-g
$hash
'
).
frameworkVersionFor
(
hash
),
'98.76.55-pre.32'
);
expect
(
GitTagVersion
.
parse
(
'v10.20.30-0-g
$hash
'
).
frameworkVersionFor
(
hash
),
'10.20.30'
);
expect
(
GitTagVersion
.
parse
(
'v1.2.3-hotfix.1-4-g
$hash
'
).
frameworkVersionFor
(
hash
),
'1.2.3-hotfix.2-pre.4'
);
expect
(
GitTagVersion
.
parse
(
'v7.2.4-hotfix.8-0-g
$hash
'
).
frameworkVersionFor
(
hash
),
'7.2.4-hotfix.8'
);
expect
(
testLogger
.
traceText
,
''
);
expect
(
GitTagVersion
.
parse
(
'x1.2.3-4-g
$hash
'
).
frameworkVersionFor
(
hash
),
'0.0.0-unknown'
);
expect
(
GitTagVersion
.
parse
(
'v1.0.0-unknown-0-g
$hash
'
).
frameworkVersionFor
(
hash
),
'0.0.0-unknown'
);
expect
(
GitTagVersion
.
parse
(
'beta-1-g
$hash
'
).
frameworkVersionFor
(
hash
),
'0.0.0-unknown'
);
expect
(
GitTagVersion
.
parse
(
'v1.2.3-4-gx
$hash
'
).
frameworkVersionFor
(
hash
),
'0.0.0-unknown'
);
expect
(
testLogger
.
statusText
,
''
);
expect
(
testLogger
.
errorText
,
''
);
expect
(
testLogger
.
traceText
,
'Could not interpret results of "git describe": x1.2.3-4-gabcdef
\n
'
'Could not interpret results of "git describe": v1.0.0-unknown-0-gabcdef
\n
'
'Could not interpret results of "git describe": beta-1-gabcdef
\n
'
'Could not interpret results of "git describe": v1.2.3-4-gxabcdef
\n
'
);
});
}
void
_expectVersionMessage
(
String
message
)
{
...
...
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