2 declare(strict_types = 1);
25 use Composer\Script\Event;
26 use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
27 use TYPO3\CMS\Composer\Plugin\Util\Filesystem;
33 $symfonyFilesystem =
new SymfonyFilesystem();
34 $filesystem =
new Filesystem();
36 $filesystem->copy(
'Build/git-hooks/commit-msg',
'.git/hooks/commit-msg');
37 if (!is_executable(
'.git/hooks/commit-msg')) {
38 $symfonyFilesystem->chmod(
'.git/hooks/commit-msg', 0755);
40 }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) {
41 $event->getIO()->writeError(
'<warning>Exception:enableCommitMessageHook:' . $e->getMessage() .
'</warning>');
47 if (DIRECTORY_SEPARATOR ===
'\\') {
50 $symfonyFilesystem =
new SymfonyFilesystem();
51 $filesystem =
new Filesystem();
53 $filesystem->copy(
'Build/git-hooks/unix+mac/pre-commit',
'.git/hooks/pre-commit');
54 if (!is_executable(
'.git/hooks/pre-commit')) {
55 $symfonyFilesystem->chmod(
'.git/hooks/pre-commit', 0755);
57 }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) {
58 $event->getIO()->writeError(
'<warning>Exception:enablePreCommitHook:' . $e->getMessage() .
'</warning>');
64 $filesystem =
new Filesystem();
65 $filesystem->remove(
'.git/hooks/pre-commit');