This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Robo\Task\Vcs; |
||
4 | |||
5 | use Robo\Task\CommandStack; |
||
6 | use Robo\Common\ProcessUtils; |
||
7 | |||
8 | /** |
||
9 | * Runs Git commands in stack. You can use `stopOnFail()` to point that stack should be terminated on first fail. |
||
10 | * |
||
11 | * ``` php |
||
12 | * <?php |
||
13 | * $this->taskGitStack() |
||
14 | * ->stopOnFail() |
||
15 | * ->add('-A') |
||
16 | * ->commit('adding everything') |
||
17 | * ->push('origin','master') |
||
18 | * ->tag('0.6.0') |
||
19 | * ->push('origin','0.6.0') |
||
20 | * ->run() |
||
21 | * |
||
22 | * $this->taskGitStack() |
||
23 | * ->stopOnFail() |
||
24 | * ->add('doc/*') |
||
25 | * ->commit('doc updated') |
||
26 | * ->push() |
||
27 | * ->run(); |
||
28 | * ?> |
||
29 | * ``` |
||
30 | */ |
||
31 | class GitStack extends CommandStack |
||
32 | { |
||
33 | /** |
||
34 | * @param string $pathToGit |
||
35 | */ |
||
36 | public function __construct($pathToGit = 'git') |
||
37 | { |
||
38 | $this->executable = $pathToGit; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Executes `git clone` |
||
43 | * |
||
44 | * @param string $repo |
||
45 | * @param string $to |
||
46 | * @param string $branch |
||
47 | * |
||
48 | * @return $this |
||
49 | */ |
||
50 | View Code Duplication | public function cloneRepo($repo, $to = "", $branch = "") |
|
51 | { |
||
52 | $cmd = ['clone', $repo, $to]; |
||
53 | if (!empty($branch)) { |
||
54 | $cmd[] = "--branch $branch"; |
||
55 | } |
||
56 | return $this->exec($cmd); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Executes `git clone` with depth 1 as default |
||
61 | * |
||
62 | * @param string $repo |
||
63 | * @param string $to |
||
64 | * @param string $branch |
||
65 | * @param int $depth |
||
66 | * |
||
67 | * @return $this |
||
68 | */ |
||
69 | View Code Duplication | public function cloneShallow($repo, $to = '', $branch = "", $depth = 1) |
|
0 ignored issues
–
show
|
|||
70 | { |
||
71 | $cmd = ["clone --depth $depth", $repo, $to]; |
||
72 | if (!empty($branch)) { |
||
73 | $cmd[] = "--branch $branch"; |
||
74 | } |
||
75 | |||
76 | return $this->exec($cmd); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Executes `git add` command with files to add pattern |
||
81 | * |
||
82 | * @param string $pattern |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function add($pattern) |
||
87 | { |
||
88 | return $this->exec([__FUNCTION__, $pattern]); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Executes `git commit` command with a message |
||
93 | * |
||
94 | * @param string $message |
||
95 | * @param string $options |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function commit($message, $options = "") |
||
100 | { |
||
101 | $message = ProcessUtils::escapeArgument($message); |
||
0 ignored issues
–
show
The method
Robo\Common\ProcessUtils::escapeArgument() has been deprecated with message: since version 3.3, to be removed in 4.0. Use a command line array or give env vars to the `Process::start/run()` method instead.
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
102 | return $this->exec([__FUNCTION__, "-m $message", $options]); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Executes `git pull` command. |
||
107 | * |
||
108 | * @param string $origin |
||
109 | * @param string $branch |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function pull($origin = '', $branch = '') |
||
114 | { |
||
115 | return $this->exec([__FUNCTION__, $origin, $branch]); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * Executes `git push` command |
||
120 | * |
||
121 | * @param string $origin |
||
122 | * @param string $branch |
||
123 | * |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function push($origin = '', $branch = '') |
||
127 | { |
||
128 | return $this->exec([__FUNCTION__, $origin, $branch]); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Performs git merge |
||
133 | * |
||
134 | * @param string $branch |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | public function merge($branch) |
||
139 | { |
||
140 | return $this->exec([__FUNCTION__, $branch]); |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Executes `git checkout` command |
||
145 | * |
||
146 | * @param string $branch |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function checkout($branch) |
||
151 | { |
||
152 | return $this->exec([__FUNCTION__, $branch]); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * Executes `git tag` command |
||
157 | * |
||
158 | * @param string $tag_name |
||
159 | * @param string $message |
||
160 | * |
||
161 | * @return $this |
||
162 | */ |
||
163 | View Code Duplication | public function tag($tag_name, $message = "") |
|
164 | { |
||
165 | if ($message != "") { |
||
166 | $message = "-m '$message'"; |
||
167 | } |
||
168 | return $this->exec([__FUNCTION__, $message, $tag_name]); |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * {@inheritdoc} |
||
173 | */ |
||
174 | public function run() |
||
175 | { |
||
176 | $this->printTaskInfo("Running git commands..."); |
||
177 | return parent::run(); |
||
178 | } |
||
179 | } |
||
180 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.