‪TYPO3CMS  10.4
InstallerScripts.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
5 
6 /***************************************************************
7  * Copyright notice
8  *
9  * (c) 2018 Helmut Hummel <info@helhum.io>
10  * All rights reserved
11  *
12  * The GNU General Public License can be found at
13  * http://www.gnu.org/copyleft/gpl.html.
14  * A copy is found in the text file GPL.txt and important notices to the license
15  * from the author is found in LICENSE.txt distributed with these scripts.
16  *
17  *
18  * This script is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * This copyright notice MUST APPEAR in all copies of the script!
24  ***************************************************************/
25 
26 use Composer\Script\Event;
27 use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
28 use TYPO3\CMS\Composer\Plugin\Util\Filesystem;
29 
31 {
32  public static function ‪enableCommitMessageHook(Event $event)
33  {
34  $symfonyFilesystem = new SymfonyFilesystem();
35  $filesystem = new Filesystem();
36  try {
37  $filesystem->copy('Build/git-hooks/commit-msg', '.git/hooks/commit-msg');
38  if (!is_executable('.git/hooks/commit-msg')) {
39  $symfonyFilesystem->chmod('.git/hooks/commit-msg', 0755);
40  }
41  } catch (\Symfony\Component\Filesystem\Exception\IOException $e) {
42  $event->getIO()->writeError('<warning>Exception:enableCommitMessageHook:' . $e->getMessage() . '</warning>');
43  }
44  }
45 
46  public static function ‪enablePreCommitHook(Event $event)
47  {
48  if (DIRECTORY_SEPARATOR === '\\') {
49  return;
50  }
51  $symfonyFilesystem = new SymfonyFilesystem();
52  $filesystem = new Filesystem();
53  try {
54  $filesystem->copy('Build/git-hooks/unix+mac/pre-commit', '.git/hooks/pre-commit');
55  if (!is_executable('.git/hooks/pre-commit')) {
56  $symfonyFilesystem->chmod('.git/hooks/pre-commit', 0755);
57  }
58  } catch (\Symfony\Component\Filesystem\Exception\IOException $e) {
59  $event->getIO()->writeError('<warning>Exception:enablePreCommitHook:' . $e->getMessage() . '</warning>');
60  }
61  }
62 
63  public static function ‪disablePreCommitHook(Event $event)
64  {
65  $filesystem = new Filesystem();
66  $filesystem->remove('.git/hooks/pre-commit');
67  }
68 }
‪TYPO3\CMS\Composer\Scripts\InstallerScripts
Definition: InstallerScripts.php:31
‪TYPO3\CMS\Composer\Scripts
Definition: InstallerScripts.php:4
‪TYPO3\CMS\Composer\Scripts\InstallerScripts\enableCommitMessageHook
‪static enableCommitMessageHook(Event $event)
Definition: InstallerScripts.php:32
‪TYPO3\CMS\Composer\Scripts\InstallerScripts\disablePreCommitHook
‪static disablePreCommitHook(Event $event)
Definition: InstallerScripts.php:63
‪TYPO3\CMS\Composer\Scripts\InstallerScripts\enablePreCommitHook
‪static enablePreCommitHook(Event $event)
Definition: InstallerScripts.php:46