feat: add and enable pre-push Git hooks

This commit is contained in:
Oliver Davies 2023-04-24 22:54:34 +01:00
parent c419332bad
commit 2afdf43cd2
4 changed files with 54 additions and 1 deletions

View file

@ -142,6 +142,10 @@ class GenerateCommand extends Command
if ($filesystem->exists("{$outputDir}/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php")) {
$filesystem->chmod("{$outputDir}/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php", 0755);
}
if ($filesystem->exists("{$outputDir}/.githooks/pre-push")) {
$filesystem->chmod("{$outputDir}/.githooks/pre-push", 0755);
}
}
function getFiles(array $configurationData): Collection
@ -219,6 +223,14 @@ class GenerateCommand extends Command
);
}
if (Arr::get($configurationData, 'experimental.runGitHooksBeforePush', false) === true) {
$filesToGenerate[] = new TemplateFile(
data: 'git-hooks/pre-push',
name: 'pre-push',
path: '.githooks',
);
}
return $filesToGenerate;
}

View file

@ -40,6 +40,7 @@ final class Config
allowMissingFields: true,
fields: [
'createGitHubActionsConfiguration' => new Assert\Type('boolean'),
'runGitHooksBeforePush' => new Assert\Type('boolean'),
'useNewDatabaseCredentials' => new Assert\Type('boolean'),
]
)]