1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* GitElephant - An abstraction layer for git written in PHP |
5
|
|
|
* Copyright (C) 2013 Matteo Giachino |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with this program. If not, see [http://www.gnu.org/licenses/]. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace GitElephant\Command; |
22
|
|
|
|
23
|
|
|
use GitElephant\Repository; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* show command generator |
27
|
|
|
* |
28
|
|
|
* @author Matteo Giachino <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
class ShowCommand extends BaseCommand |
31
|
|
|
{ |
32
|
|
|
public const GIT_SHOW = 'show'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* constructor |
36
|
|
|
* |
37
|
|
|
* @param \GitElephant\Repository $repo The repository object this command |
38
|
|
|
* will interact with |
39
|
|
|
*/ |
40
|
18 |
|
public function __construct(Repository $repo = null) |
41
|
|
|
{ |
42
|
18 |
|
parent::__construct($repo); |
43
|
18 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* build the show command |
47
|
|
|
* |
48
|
|
|
* @param string|\GitElephant\Objects\Commit $ref the reference for the show command |
49
|
|
|
* |
50
|
|
|
* @throws \RuntimeException |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
18 |
|
public function showCommit($ref): string |
54
|
|
|
{ |
55
|
18 |
|
$this->clearAll(); |
56
|
|
|
|
57
|
18 |
|
$this->addCommandName(self::GIT_SHOW); |
58
|
18 |
|
$this->addCommandArgument('-s'); |
59
|
18 |
|
$this->addCommandArgument('--pretty=raw'); |
60
|
18 |
|
$this->addCommandArgument('--no-color'); |
61
|
18 |
|
$this->addCommandSubject($ref); |
|
|
|
|
62
|
|
|
|
63
|
18 |
|
return $this->getCommand(); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.