hiqdev /
chkipper
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Changelog keeper |
||
| 4 | * |
||
| 5 | * @link https://github.com/hiqdev/chkipper |
||
| 6 | * @package chkipper |
||
| 7 | * @license BSD-3-Clause |
||
| 8 | * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace hiqdev\chkipper\lib\modifiers; |
||
| 12 | |||
| 13 | use hiqdev\chkipper\lib\History; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Modifier that adds links for commits without link. |
||
| 17 | * |
||
| 18 | * @author Andrii Vasyliev <[email protected]> |
||
| 19 | */ |
||
| 20 | class AddCommitLinks extends AbstractModifier |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * {@inheritdoc} |
||
| 24 | */ |
||
| 25 | 2 | public function run(History $history) |
|
| 26 | { |
||
| 27 | 2 | foreach ($history->getHashes() as $hash) { |
|
| 28 | 2 | if (!$history->hasLink($hash)) { |
|
| 29 | 1 | $history->addLink($hash, static::generateCommitHref($history, $hash)); |
|
| 30 | 1 | } |
|
| 31 | 2 | } |
|
| 32 | 2 | } |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Generates href to a commit. |
||
| 36 | * @param History $history history object |
||
| 37 | * @param string $hash commit hash |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | 1 | public static function generateCommitHref(History $history, $hash) |
|
| 41 | { |
||
| 42 | 1 | $project = $history->getProject(); |
|
| 43 | 1 | $rmsSite = $history->getConfig()->rmsSite; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 44 | |||
| 45 | 1 | return "https://$rmsSite/$project/commit/$hash"; |
|
| 46 | } |
||
| 47 | } |
||
| 48 |