These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Robo\Task\Vcs; |
||
3 | |||
4 | use Robo\Contract\CommandInterface; |
||
5 | use Robo\Result; |
||
6 | use Robo\Task\CommandStack; |
||
7 | |||
8 | /** |
||
9 | * Runs Svn commands in stack. You can use `stopOnFail()` to point that stack should be terminated on first fail. |
||
10 | * |
||
11 | * ``` php |
||
12 | * <?php |
||
13 | * $this->taskSvnStack() |
||
14 | * ->checkout('http://svn.collab.net/repos/svn/trunk') |
||
15 | * ->run() |
||
16 | * |
||
17 | * // alternatively |
||
18 | * $this->_svnCheckout('http://svn.collab.net/repos/svn/trunk'); |
||
19 | * |
||
20 | * $this->taskSvnStack('username', 'password') |
||
21 | * ->stopOnFail() |
||
22 | * ->update() |
||
23 | * ->add('doc/*') |
||
24 | * ->commit('doc updated') |
||
25 | * ->run(); |
||
26 | * ?> |
||
27 | * ``` |
||
28 | */ |
||
29 | class SvnStack extends CommandStack implements CommandInterface |
||
30 | { |
||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $stopOnFail = false; |
||
35 | |||
36 | /** |
||
37 | * @var \Robo\Result |
||
38 | */ |
||
39 | protected $result; |
||
40 | |||
41 | /** |
||
42 | * @param string $username |
||
43 | * @param string $password |
||
44 | * @param string $pathToSvn |
||
45 | */ |
||
46 | public function __construct($username = '', $password = '', $pathToSvn = 'svn') |
||
47 | { |
||
48 | $this->executable = $pathToSvn; |
||
49 | if (!empty($username)) { |
||
50 | $this->executable .= " --username $username"; |
||
51 | } |
||
52 | if (!empty($password)) { |
||
53 | $this->executable .= " --password $password"; |
||
54 | } |
||
55 | $this->result = Result::success($this); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Updates `svn update` command |
||
60 | * |
||
61 | * @param string $path |
||
62 | * |
||
63 | * @return $this; |
||
0 ignored issues
–
show
|
|||
64 | */ |
||
65 | public function update($path = '') |
||
66 | { |
||
67 | return $this->exec("update $path"); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Executes `svn add` command with files to add pattern |
||
72 | * |
||
73 | * @param string $pattern |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | public function add($pattern = '') |
||
78 | { |
||
79 | return $this->exec("add $pattern"); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Executes `svn commit` command with a message |
||
84 | * |
||
85 | * @param string $message |
||
86 | * @param string $options |
||
87 | * |
||
88 | * @return $this |
||
89 | */ |
||
90 | public function commit($message, $options = "") |
||
91 | { |
||
92 | return $this->exec("commit -m '$message' $options"); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Executes `svn checkout` command |
||
97 | * |
||
98 | * @param string $branch |
||
99 | * |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function checkout($branch) |
||
103 | { |
||
104 | return $this->exec("checkout $branch"); |
||
105 | } |
||
106 | } |
||
107 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.