1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* GitElephant - An abstraction layer for git written in PHP |
4
|
|
|
* Copyright (C) 2013 Matteo Giachino |
5
|
|
|
* |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU General Public License as published by |
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU General Public License |
17
|
|
|
* along with this program. If not, see [http://www.gnu.org/licenses/]. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace GitElephant\Command\Remote; |
21
|
|
|
|
22
|
|
|
use \GitElephant\Command\SubCommandCommand; |
23
|
|
|
use \GitElephant\Repository; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class ShowRemoteCommand |
27
|
|
|
* |
28
|
|
|
* remote subcommand generator for show |
29
|
|
|
* |
30
|
|
|
* @package GitElephant\Objects |
31
|
|
|
* @author David Neimeyer <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
|
34
|
|
|
class ShowSubCommand extends SubCommandCommand |
35
|
|
|
{ |
36
|
|
|
const GIT_REMOTE_SHOW = 'show'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* constructor |
40
|
|
|
* |
41
|
|
|
* @param \GitElephant\Repository $repo The repository object this command |
42
|
|
|
* will interact with |
43
|
|
|
*/ |
44
|
3 |
|
public function __construct(Repository $repo = null) |
45
|
|
|
{ |
46
|
3 |
|
parent::__construct($repo); |
47
|
3 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* build show sub command |
51
|
|
|
* |
52
|
|
|
* NOTE: for technical reasons $name is optional, however under normal |
53
|
|
|
* implementation it SHOULD be passed! |
54
|
|
|
* |
55
|
|
|
* @param string $name |
56
|
|
|
* @param bool $queryRemotes Fetch new information from remotes |
57
|
|
|
* |
58
|
|
|
* @return ShowSubCommand |
59
|
|
|
*/ |
60
|
3 |
|
public function prepare($name = null, $queryRemotes = true) |
61
|
|
|
{ |
62
|
3 |
|
$this->addCommandName(self::GIT_REMOTE_SHOW); |
63
|
|
|
/** |
64
|
|
|
* only add subject if relevant, |
65
|
|
|
* otherwise on repositories without a remote defined (ie, fresh |
66
|
|
|
* init'd or mock) will likely trigger warning/error condition |
67
|
|
|
* |
68
|
|
|
*/ |
69
|
3 |
|
if ($name) { |
|
|
|
|
70
|
2 |
|
$this->addCommandSubject($name); |
71
|
2 |
|
} |
72
|
|
|
|
73
|
3 |
|
if (!$queryRemotes) { |
74
|
1 |
|
$this->addCommandArgument('-n'); |
75
|
1 |
|
} |
76
|
|
|
|
77
|
3 |
|
return $this; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: