validate method
Implementation
@override
Future<ValidationCheck> validate(ReleaseContext context) async {
final output = _output ?? TerminalOutput();
final envName = context.config.environmentName ??
context.environment['ENVIRONMENT'] ??
context.environment['ENV'];
final target = TargetEnvironment.parse(envName ?? 'default');
if (target != TargetEnvironment.production) {
return ValidationCheck(
name: name,
status: CheckStatus.passed,
message: 'Non-production environment target (${target.name})',
);
}
// Print clear production release warning summary
output.warning('\n==================================================');
output.warning(' PRODUCTION RELEASE SAFETY GATE ');
output.warning('==================================================');
output.info('Environment: PRODUCTION');
output.info('Release Mode: ${context.type.displayName}');
output.info('Platform: ${context.targetPlatform ?? "android"}');
output.info(
'Version: ${context.versionName ?? "Auto"}+${context.buildNumber ?? "Auto"}');
output.info('Flavor: ${context.config.flavor ?? "default"}');
output.info('Path: ${context.projectPath}');
output.warning('==================================================\n');
// Strict git working tree check for production releases
final isGitRepo = await _gitClient.isGitRepository(context.projectPath);
if (isGitRepo) {
final isClean = await _gitClient.hasCleanWorkingTree(context.projectPath);
final allowDirty = context.config.allowDirty || context.allowDirty;
if (!isClean && !allowDirty) {
return ValidationCheck(
name: name,
status: CheckStatus.failed,
message:
'Production safety violation: Working tree has uncommitted changes. Commit/stash changes or specify --allow-dirty.',
);
}
}
return ValidationCheck(
name: name,
status: CheckStatus.passed,
message: 'Production release safety criteria satisfied.',
);
}