flutter_tools/version: git log.showSignature=false (#38576)
This commit is contained in:
@@ -662,7 +662,7 @@ int _getPrNumber() {
|
||||
Future<String> _getAuthors() async {
|
||||
final String exe = Platform.isWindows ? '.exe' : '';
|
||||
final String author = await runAndGetStdout(
|
||||
'git$exe', <String>['log', _getGitHash(), '--pretty="%an <%ae>"'],
|
||||
'git$exe', <String>['-c', 'log.showSignature=false', 'log', _getGitHash(), '--pretty="%an <%ae>"'],
|
||||
workingDirectory: flutterRoot,
|
||||
).first;
|
||||
return author;
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'globals.dart';
|
||||
class FlutterVersion {
|
||||
@visibleForTesting
|
||||
FlutterVersion([this._clock = const SystemClock()]) {
|
||||
_frameworkRevision = _runGit('git log -n 1 --pretty=format:%H');
|
||||
_frameworkRevision = _runGit(gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '));
|
||||
_frameworkVersion = GitTagVersion.determine().frameworkVersionFor(_frameworkRevision);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class FlutterVersion {
|
||||
|
||||
String _frameworkAge;
|
||||
String get frameworkAge {
|
||||
return _frameworkAge ??= _runGit('git log -n 1 --pretty=format:%ar');
|
||||
return _frameworkAge ??= _runGit(gitLog(<String>['-n', '1', '--pretty=format:%ar']).join(' '));
|
||||
}
|
||||
|
||||
String _frameworkVersion;
|
||||
@@ -134,15 +134,13 @@ class FlutterVersion {
|
||||
String get frameworkCommitDate => _latestGitCommitDate();
|
||||
|
||||
static String _latestGitCommitDate([ String branch ]) {
|
||||
final List<String> args = <String>[
|
||||
'git',
|
||||
'log',
|
||||
final List<String> args = gitLog(<String>[
|
||||
if (branch != null) branch,
|
||||
'-n',
|
||||
'1',
|
||||
'--pretty=format:%ad',
|
||||
'--date=iso',
|
||||
];
|
||||
]);
|
||||
return _runSync(args, lenient: false);
|
||||
}
|
||||
|
||||
@@ -332,6 +330,14 @@ class FlutterVersion {
|
||||
}
|
||||
}
|
||||
|
||||
/// log.showSignature=false is a user setting and it will break things,
|
||||
/// so we want to disable it for every git log call. This is a convenience
|
||||
/// wrapper that does that.
|
||||
@visibleForTesting
|
||||
static List<String> gitLog(List<String> args) {
|
||||
return <String>['git', '-c', 'log.showSignature=false', 'log'] + args;
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
static String versionOutOfDateMessage(Duration frameworkAge) {
|
||||
String warning = 'WARNING: your installation of Flutter is ${frameworkAge.inDays} days old.';
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/version.dart';
|
||||
import 'package:flutter_tools/src/version.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
@@ -116,7 +117,7 @@ class MockProcessManager extends Mock implements ProcessManager {
|
||||
Encoding stderrEncoding = systemEncoding,
|
||||
}) {
|
||||
final String commandStr = command.join(' ');
|
||||
if (commandStr == 'git log -n 1 --pretty=format:%H') {
|
||||
if (commandStr == FlutterVersion.gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' ')) {
|
||||
return ProcessResult(0, 0, '000000000000000000000', '');
|
||||
}
|
||||
if (commandStr ==
|
||||
|
||||
@@ -132,7 +132,7 @@ void main() {
|
||||
testUsingContext('checks that Flutter toJson output reports the flutter framework version', () async {
|
||||
final ProcessResult result = ProcessResult(0, 0, 'random', '0');
|
||||
|
||||
when(processManager.runSync('git log -n 1 --pretty=format:%H'.split(' '),
|
||||
when(processManager.runSync(FlutterVersion.gitLog('-n 1 --pretty=format:%H'.split(' ')),
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
when(processManager.runSync('git rev-parse --abbrev-ref --symbolic @{u}'.split(' '),
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
@@ -140,11 +140,11 @@ void main() {
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
when(processManager.runSync('git ls-remote --get-url master'.split(' '),
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
when(processManager.runSync('git log -n 1 --pretty=format:%ar'.split(' '),
|
||||
when(processManager.runSync(FlutterVersion.gitLog('-n 1 --pretty=format:%ar'.split(' ')),
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
when(processManager.runSync('git describe --match v*.*.* --first-parent --long --tags'.split(' '),
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
when(processManager.runSync('git log -n 1 --pretty=format:%ad --date=iso'.split(' '),
|
||||
when(processManager.runSync(FlutterVersion.gitLog('-n 1 --pretty=format:%ad --date=iso'.split(' ')),
|
||||
workingDirectory: Cache.flutterRoot)).thenReturn(result);
|
||||
|
||||
final FakeFlutterVersion version = FakeFlutterVersion();
|
||||
|
||||
@@ -465,14 +465,18 @@ void fakeData(
|
||||
});
|
||||
|
||||
final Answering<ProcessResult> syncAnswer = (Invocation invocation) {
|
||||
bool argsAre(String a1, [ String a2, String a3, String a4, String a5, String a6, String a7, String a8 ]) {
|
||||
bool argsAre(String a1, [ String a2, String a3, String a4, String a5, String a6, String a7, String a8, String a9 ]) {
|
||||
const ListEquality<String> equality = ListEquality<String>();
|
||||
final List<String> args = invocation.positionalArguments.single;
|
||||
final List<String> expectedArgs = <String>[a1, a2, a3, a4, a5, a6, a7, a8].where((String arg) => arg != null).toList();
|
||||
final List<String> expectedArgs = <String>[a1, a2, a3, a4, a5, a6, a7, a8, a9].where((String arg) => arg != null).toList();
|
||||
return equality.equals(args, expectedArgs);
|
||||
}
|
||||
|
||||
if (argsAre('git', 'log', '-n', '1', '--pretty=format:%ad', '--date=iso')) {
|
||||
bool listArgsAre(List<String> a) {
|
||||
return Function.apply(argsAre, a);
|
||||
}
|
||||
|
||||
if (listArgsAre(FlutterVersion.gitLog(<String>['-n', '1', '--pretty=format:%ad', '--date=iso']))) {
|
||||
return success(localCommitDate.toString());
|
||||
} else if (argsAre('git', 'remote')) {
|
||||
return success('');
|
||||
@@ -483,7 +487,8 @@ void fakeData(
|
||||
fail('Did not expect server ping');
|
||||
}
|
||||
return errorOnFetch ? failure(128) : success('');
|
||||
} else if (remoteCommitDate != null && argsAre('git', 'log', '__flutter_version_check__/$channel', '-n', '1', '--pretty=format:%ad', '--date=iso')) {
|
||||
// Careful here! argsAre accepts 9 arguments and FlutterVersion.gitLog adds 4.
|
||||
} else if (remoteCommitDate != null && listArgsAre(FlutterVersion.gitLog(<String>['__flutter_version_check__/$channel', '-n', '1', '--pretty=format:%ad', '--date=iso']))) {
|
||||
return success(remoteCommitDate.toString());
|
||||
}
|
||||
|
||||
@@ -506,12 +511,12 @@ void fakeData(
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(ProcessResult(102, 0, 'branch', ''));
|
||||
when(pm.runSync(
|
||||
<String>['git', 'log', '-n', '1', '--pretty=format:%H'],
|
||||
FlutterVersion.gitLog(<String>['-n', '1', '--pretty=format:%H']),
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(ProcessResult(103, 0, '1234abcd', ''));
|
||||
when(pm.runSync(
|
||||
<String>['git', 'log', '-n', '1', '--pretty=format:%ar'],
|
||||
FlutterVersion.gitLog(<String>['-n', '1', '--pretty=format:%ar']),
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenReturn(ProcessResult(104, 0, '1 second ago', ''));
|
||||
|
||||
Reference in New Issue
Block a user