|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of CaptainHook. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace sebastianfeldmann\CaptainHook\Console\Command\Hook; |
|
11
|
|
|
|
|
12
|
|
|
use sebastianfeldmann\CaptainHook\Config; |
|
13
|
|
|
use sebastianfeldmann\CaptainHook\Console\Command\Hook; |
|
14
|
|
|
use sebastianfeldmann\CaptainHook\Git; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class CommitMessage |
|
21
|
|
|
* |
|
22
|
|
|
* @package CaptainHook |
|
23
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
24
|
|
|
* @link https://github.com/sebastianfeldmann/captainhook |
|
25
|
|
|
* @since Class available since Release 0.9.0 |
|
26
|
|
|
*/ |
|
27
|
|
|
class CommitMsg extends Hook |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Hook to execute. |
|
31
|
|
|
* |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $hookName = 'commit-msg'; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Configure the command. |
|
38
|
|
|
*/ |
|
39
|
2 |
|
protected function configure() |
|
40
|
|
|
{ |
|
41
|
2 |
|
parent::configure(); |
|
42
|
2 |
|
$this->addArgument('file', InputArgument::REQUIRED, 'File containing the commit message.'); |
|
43
|
2 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Read the commit message from file. |
|
47
|
|
|
* |
|
48
|
|
|
* |
|
49
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
|
50
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
|
51
|
|
|
* @param \sebastianfeldmann\CaptainHook\Config $config |
|
52
|
|
|
* @param \sebastianfeldmann\CaptainHook\Git\Repository $repository |
|
53
|
|
|
* @internal param \sebastianfeldmann\CaptainHook\Console\Command\Hook\IO $io |
|
54
|
|
|
*/ |
|
55
|
1 |
|
protected function setup(InputInterface $input, OutputInterface $output, Config $config, Git\Repository $repository) |
|
56
|
|
|
{ |
|
57
|
1 |
|
$repository->setCommitMsg(Git\CommitMessage::createFromFile($input->getFirstArgument())); |
|
58
|
1 |
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|