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