execute method
Execute this build step.
The context provides access to the build configuration and logger.
Returns a NativeStepResult containing any artifacts produced by this step.
Implementation
@override
Future<NativeStepResult> execute(
NativeBuildContext context,
ResolvedSource source,
) async {
final logger = context.logger;
logger?.info('[git_apply_patch] Applying patch');
final r = runner ?? ProcessRunner(logger: logger);
final resolvedPatchPath = expandRecipeValue(patchPath, context, source);
final patch = p.isAbsolute(resolvedPatchPath)
? resolvedPatchPath
: p.join(source.directory.path, resolvedPatchPath);
final resolvedTargetDirectory = targetDirectory == null
? context.directories.work.path
: expandRecipeValue(targetDirectory!, context, source);
final target = p.isAbsolute(resolvedTargetDirectory)
? resolvedTargetDirectory
: p.join(context.directories.work.path, resolvedTargetDirectory);
logger?.info('[git_apply_patch] Patch: $patch');
logger?.info('[git_apply_patch] Target: $target');
await r.runStreaming('git', [
'apply',
patch,
], workingDirectory: Directory(target));
logger?.info('[git_apply_patch] Patch applied');
return const NativeStepResult();
}