1 | <?php |
||
8 | class Scripts |
||
9 | { |
||
10 | const BACKUP_EXTENSION = '.bak'; |
||
11 | const GIT_PATH = '.git'; |
||
12 | const HOOKS_PATH = 'hooks'; |
||
13 | const HOOK_FILENAME = 'commit-msg'; |
||
14 | const TEMPLATE_FILENAME = '.gitmessage'; |
||
15 | |||
16 | /** |
||
17 | * Default Permissions (Copied from example hooks) |
||
18 | * |
||
19 | * User: Read, Write, Execute |
||
20 | * Group: Read, Execute |
||
21 | * Other: Execute |
||
22 | */ |
||
23 | const EXECUTABLE_PERMISSIONS = 0751; |
||
24 | const HOOK_CONTENTS = <<<CONTENT |
||
25 | #!/bin/sh |
||
26 | |||
27 | vendor/bin/git-lint-validators git-lint-validator:hook $1 |
||
28 | CONTENT; |
||
29 | |||
30 | const TEMPLATE_CONTENTS = <<<CONTENT |
||
31 | Subject line |
||
32 | |||
33 | # - Capitalise the subject line and do not end it with a period |
||
34 | # - Use the imperative mood in the subject line |
||
35 | # - Summarise changes in around 50 (soft limit, hard limit at 69) |
||
36 | # characters or less in the subject line |
||
37 | # - Separate subject line from body with a blank line |
||
38 | Subject body |
||
39 | # - Use the subject body to explain what and why vs. how |
||
40 | # - Wrap the subject body at 72 characters |
||
41 | |||
42 | CONTENT; |
||
43 | |||
44 | /** |
||
45 | * Installs and activates the Git commit message |
||
46 | * hook when confirmed by the user. An existing hook |
||
47 | * is backed with the .bak extension. |
||
48 | * |
||
49 | * @param Event $event The script event. |
||
50 | * |
||
51 | * @return boolean |
||
52 | */ |
||
53 | public static function installGitMessageHook(Event $event) |
||
102 | |||
103 | /** |
||
104 | * Installs and configures the Git commit message |
||
105 | * template when confirmed by the user. |
||
106 | * |
||
107 | * @param Event $event The script event. |
||
108 | * |
||
109 | * @return boolean |
||
110 | */ |
||
111 | public static function installGitCommitMessageTemplate(Event $event) |
||
150 | |||
151 | /** |
||
152 | * Returns the .git directory if present. Errors the given |
||
153 | * message if not. |
||
154 | * |
||
155 | * @param string $message The message to error. |
||
156 | * @param IOInterface $inputOutput The Input/Output helper interface. |
||
157 | * |
||
158 | * @return false|string |
||
159 | */ |
||
160 | private static function getGuardedGitDirectory($message, IOInterface $inputOutput) |
||
171 | } |
||
172 |