Unverified Commit bacaab97 authored by Stanislav Baranov's avatar Stanislav Baranov Committed by GitHub

Allow dynamic patches without a patch number. (#25796)

Unique patch numbers are mainly useful for canary and A-B testing, but otherwise complicate things and can now be omitted.
parent 52bd2ccb
......@@ -469,8 +469,14 @@ Future<void> _buildGradleProjectV2(
update.addFile(ArchiveFile(name, newFile.content.length, newFile.content));
}
final File updateFile = fs.directory(buildInfo.patchDir)
.childFile('${package.versionCode}-${buildInfo.patchNumber}.zip');
File updateFile;
if (buildInfo.patchNumber != null) {
updateFile = fs.directory(buildInfo.patchDir)
.childFile('${package.versionCode}-${buildInfo.patchNumber}.zip');
} else {
updateFile = fs.directory(buildInfo.patchDir)
.childFile('${package.versionCode}.zip');
}
if (update.files.isEmpty) {
printStatus('No changes detected relative to baseline build.');
......@@ -490,9 +496,14 @@ Future<void> _buildGradleProjectV2(
final Map<String, dynamic> manifest = <String, dynamic>{
'baselineChecksum': baselineChecksum,
'buildNumber': package.versionCode,
'patchNumber': buildInfo.patchNumber,
};
if (buildInfo.patchNumber != null) {
manifest.addAll(<String, dynamic>{
'patchNumber': buildInfo.patchNumber,
});
}
const JsonEncoder encoder = JsonEncoder.withIndent(' ');
final String manifestJson = encoder.convert(manifest);
update.addFile(ArchiveFile('manifest.json', manifestJson.length, manifestJson.codeUnits));
......
......@@ -54,7 +54,7 @@ class BuildInfo {
final bool createPatch;
/// Internal version number of dynamic patch (not displayed to users).
/// Each patch should have a unique number to differentiate from previous
/// Each patch may have a unique number to differentiate from previous
/// patches for the same versionCode on Android or CFBundleVersion on iOS.
final int patchNumber;
......
......@@ -261,11 +261,13 @@ abstract class FlutterCommand extends Command<void> {
void addDynamicPatchingFlags({bool verboseHelp = false}) {
argParser.addOption('patch-number',
defaultsTo: '1',
hide: !verboseHelp,
help: 'An integer used as an internal version number for dynamic patch.\n'
'Each update should have a unique number to differentiate from previous '
'Each update may have a unique number to differentiate from previous\n'
'patches for same \'versionCode\' on Android or \'CFBundleVersion\' on iOS.\n'
'This optional setting allows several dynamic patches to coexist\n'
'for same baseline build, and is useful for canary and A-B testing\n'
'of dynamic patches.\n'
'This flag is only used when --dynamic --patch is specified.\n'
);
argParser.addOption('patch-dir',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment