|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of CaptainHook. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace CaptainHook\App\Hook\Condition\File; |
|
13
|
|
|
|
|
14
|
|
|
use CaptainHook\App\Console\IO; |
|
15
|
|
|
use CaptainHook\App\Git; |
|
16
|
|
|
use CaptainHook\App\Hook\Restriction; |
|
17
|
|
|
use CaptainHook\App\Hooks; |
|
18
|
|
|
use SebastianFeldmann\Git\Repository; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Trait for all Conditions checking for changed files |
|
22
|
|
|
* |
|
23
|
|
|
* Normally we would inject that functionality into the condition but since we want to have individual classes |
|
24
|
|
|
* that can be referenced in a configuration file, using a Trait is a bit of a workaround. |
|
25
|
|
|
* |
|
26
|
|
|
* @package CaptainHook |
|
27
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
28
|
|
|
* @link https://github.com/captainhook-git/captainhook |
|
29
|
|
|
* @since Class available since Release 5.27.3 |
|
30
|
|
|
*/ |
|
31
|
|
|
trait Changed |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @return \CaptainHook\App\Hook\Restriction |
|
35
|
|
|
*/ |
|
36
|
7 |
|
public static function getRestriction(): Restriction |
|
37
|
|
|
{ |
|
38
|
7 |
|
return Restriction::fromArray([Hooks::PRE_PUSH, Hooks::POST_CHECKOUT, Hooks::POST_MERGE, Hooks::POST_REWRITE]); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param \CaptainHook\App\Console\IO $io |
|
43
|
|
|
* @param \SebastianFeldmann\Git\Repository $repository |
|
44
|
|
|
* @param array<string> $diffFilter |
|
45
|
|
|
* @return array<string> |
|
46
|
|
|
*/ |
|
47
|
27 |
|
protected function getFiles(IO $io, Repository $repository, array $diffFilter): array |
|
48
|
|
|
{ |
|
49
|
27 |
|
return Git\ChangedFiles::getChangedFiles($io, $repository, $diffFilter); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|