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