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\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
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
49
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
50
|
|
|
* @param \SebastianFeldmann\CaptainHook\Config $config |
51
|
|
|
* @param \SebastianFeldmann\Git\Repository $repository |
52
|
|
|
*/ |
53
|
|
|
protected function setup(InputInterface $input, OutputInterface $output, Config $config, Git\Repository $repository) |
54
|
|
|
{ |
55
|
1 |
|
$repository->setCommitMsg(Git\CommitMessage::createFromFile($input->getFirstArgument())); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|