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
8dcb4c33
Unverified
Commit
8dcb4c33
authored
Aug 12, 2020
by
Christopher Fujino
Committed by
GitHub
Aug 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix version parsing to use git tag --points-at (#63505)
parent
c36b75e4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
39 deletions
+77
-39
version.dart
packages/flutter_tools/lib/src/version.dart
+5
-7
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+1
-1
flutter_command_runner_test.dart
...est/general.shard/runner/flutter_command_runner_test.dart
+1
-1
version_test.dart
packages/flutter_tools/test/general.shard/version_test.dart
+70
-30
No files found.
packages/flutter_tools/lib/src/version.dart
View file @
8dcb4c33
...
...
@@ -760,22 +760,20 @@ class GitTagVersion {
}
}
final
List
<
String
>
tags
=
_runGit
(
'git tag --
contains HEAD'
,
processUtils
,
workingDirectory
).
split
(
'
\n
'
);
'git tag --
points-at HEAD'
,
processUtils
,
workingDirectory
).
trim
(
).
split
(
'
\n
'
);
// Check first for a stable tag
final
RegExp
stableTagPattern
=
RegExp
(
r'^\d+\.\d+\.\d+$'
);
for
(
final
String
tag
in
tags
)
{
final
String
trimmedTag
=
tag
.
trim
();
if
(
stableTagPattern
.
hasMatch
(
trimmedTag
))
{
return
parse
(
trimmedTag
);
if
(
stableTagPattern
.
hasMatch
(
tag
.
trim
()))
{
return
parse
(
tag
);
}
}
// Next check for a dev tag
final
RegExp
devTagPattern
=
RegExp
(
r'^\d+\.\d+\.\d+-\d+\.\d+\.pre$'
);
for
(
final
String
tag
in
tags
)
{
final
String
trimmedTag
=
tag
.
trim
();
if
(
devTagPattern
.
hasMatch
(
trimmedTag
))
{
return
parse
(
trimmedTag
);
if
(
devTagPattern
.
hasMatch
(
tag
.
trim
()))
{
return
parse
(
tag
);
}
}
...
...
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
8dcb4c33
...
...
@@ -323,7 +323,7 @@ void main() {
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
,
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
,
],
stdout:
''
,
),
...
...
packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart
View file @
8dcb4c33
...
...
@@ -185,7 +185,7 @@ void main() {
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git fetch https://github.com/flutter/flutter.git --tags'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git tag --
contains
HEAD'
.
split
(
' '
),
when
(
processManager
.
runSync
(
'git tag --
points-at
HEAD'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
when
(
processManager
.
runSync
(
'git describe --match *.*.* --first-parent --long --tags'
.
split
(
' '
),
workingDirectory:
Cache
.
flutterRoot
)).
thenReturn
(
result
);
...
...
packages/flutter_tools/test/general.shard/version_test.dart
View file @
8dcb4c33
...
...
@@ -7,6 +7,7 @@ import 'dart:convert';
import
'package:collection/collection.dart'
show
ListEquality
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/process.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
...
...
@@ -458,27 +459,66 @@ void main() {
);
});
testUsingContext
(
'determine favors stable tags over dev tags'
,
()
{
final
MockProcessUtils
mockProcessUtils
=
MockProcessUtils
();
when
(
mockProcessUtils
.
runSync
(
<
String
>[
'git'
,
'tag'
,
'--contains'
,
'HEAD'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
1
,
0
,
'1.2.3-0.0.pre
\n
1.2.3
\n
1.2.3-0.1.pre'
,
''
),
<
String
>[
'git'
,
'tag'
,
'--contains'
,
'HEAD'
],
));
final
GitTagVersion
version
=
GitTagVersion
.
determine
(
mockProcessUtils
,
workingDirectory:
'.'
);
expect
(
version
.
gitTag
,
'1.2.3'
);
expect
(
version
.
devPatch
,
null
);
expect
(
version
.
devVersion
,
null
);
// We shouldn't have to fallback to git describe, because we are exactly
// on a release tag.
verifyNever
(
mockProcessUtils
.
runSync
(
<
String
>[
'git'
,
'describe'
,
'--match'
,
'*.*.*'
,
'--first-parent'
,
'--long'
,
'--tags'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
));
testUsingContext
(
'determine reports correct stable version if HEAD is at a tag'
,
()
{
const
String
stableTag
=
'1.2.3'
;
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(
<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'tag'
,
'--points-at'
,
'HEAD'
],
stdout:
stableTag
,
),
],
);
final
ProcessUtils
processUtils
=
ProcessUtils
(
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
expect
(
gitTagVersion
.
frameworkVersionFor
(
'abcd1234'
),
stableTag
);
});
testUsingContext
(
'determine favors stable tag over dev tag if both idenitfy HEAD'
,
()
{
const
String
stableTag
=
'1.2.3'
;
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(
<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'tag'
,
'--points-at'
,
'HEAD'
],
// This tests the unlikely edge case where a dev release made it to stable without any cherry picks
stdout:
'1.2.3-6.0.pre
\n
$stableTag
'
,
),
],
);
final
ProcessUtils
processUtils
=
ProcessUtils
(
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
expect
(
gitTagVersion
.
frameworkVersionFor
(
'abcd1234'
),
stableTag
);
});
testUsingContext
(
'determine reports correct git describe version if HEAD is not at a tag'
,
()
{
const
String
devTag
=
'1.2.3-2.0.pre'
;
const
String
headRevision
=
'abcd1234'
;
const
String
commitsAhead
=
'12'
;
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(
<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'tag'
,
'--points-at'
,
'HEAD'
],
stdout:
''
,
// no tag
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'describe'
,
'--match'
,
'*.*.*'
,
'--first-parent'
,
'--long'
,
'--tags'
],
stdout:
'
$devTag
-
$commitsAhead
-g
$headRevision
'
,
),
],
);
final
ProcessUtils
processUtils
=
ProcessUtils
(
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
// reported version should increment the number after the dash
expect
(
gitTagVersion
.
frameworkVersionFor
(
headRevision
),
'1.2.3-3.0.pre.12'
);
});
testUsingContext
(
'determine does not call fetch --tags'
,
()
{
...
...
@@ -494,12 +534,12 @@ void main() {
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
106
,
0
,
'v0.1.2-3-1234abcd'
,
''
),
<
String
>[
'git'
,
'describe'
]));
when
(
processUtils
.
runSync
(
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
110
,
0
,
''
,
''
),
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
));
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
...
...
@@ -539,12 +579,12 @@ void main() {
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
107
,
0
,
'v0.1.2-3-1234abcd'
,
''
),
<
String
>[
'git'
,
'describe'
]));
when
(
processUtils
.
runSync
(
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
108
,
0
,
''
,
''
),
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
));
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
,
fetchTags:
true
);
...
...
@@ -579,12 +619,12 @@ void main() {
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
109
,
0
,
''
,
''
),
<
String
>[
'git'
,
'fetch'
]));
when
(
processUtils
.
runSync
(
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
110
,
0
,
''
,
''
),
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
));
when
(
processUtils
.
runSync
(
<
String
>[
'git'
,
'describe'
,
'--match'
,
'*.*.*'
,
'--first-parent'
,
'--long'
,
'--tags'
],
...
...
@@ -624,12 +664,12 @@ void main() {
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
109
,
0
,
''
,
''
),
<
String
>[
'git'
,
'fetch'
]));
when
(
processUtils
.
runSync
(
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
RunResult
(
ProcessResult
(
110
,
0
,
''
,
''
),
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
));
when
(
processUtils
.
runSync
(
<
String
>[
'git'
,
'describe'
,
'--match'
,
'*.*.*'
,
'--first-parent'
,
'--long'
,
'--tags'
],
...
...
@@ -765,7 +805,7 @@ void fakeData(
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
ProcessResult
(
105
,
0
,
''
,
''
));
when
(
pm
.
runSync
(
<
String
>[
'git'
,
'tag'
,
'--
contains
'
,
'HEAD'
],
<
String
>[
'git'
,
'tag'
,
'--
points-at
'
,
'HEAD'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
ProcessResult
(
106
,
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