Completed
Push — master ( da729e...fa941f )
by Basil
04:01
created
dev/RepoController.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -192,6 +192,10 @@  discard block
 block discarded – undo
192 192
     	return $this->_gitWrapper;
193 193
     }
194 194
     
195
+    /**
196
+     * @param boolean $isFork
197
+     * @param boolean $exists
198
+     */
195 199
     private function summaryItem($repo, $isFork, $exists)
196 200
     {
197 201
     	return [$repo, $exists, $isFork];
@@ -202,6 +206,9 @@  discard block
 block discarded – undo
202 206
     	return 'repos' . DIRECTORY_SEPARATOR . $repo;
203 207
     }
204 208
     
209
+    /**
210
+     * @param string|boolean $username
211
+     */
205 212
     private function forkExists($username, $repo)
206 213
     {
207 214
     	return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess();
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class RepoController extends BaseDevCommand
33 33
 {
34
-	const CONFIG_VAR_USERNAME = 'username';
34
+    const CONFIG_VAR_USERNAME = 'username';
35 35
 	
36
-	const CONFIG_VAR_CLONETYPE = 'cloneType';
36
+    const CONFIG_VAR_CLONETYPE = 'cloneType';
37 37
 	
38
-	/**
39
-	 * @var string Default action is actionInit();
40
-	 */
41
-	public $defaultAction = 'init';
38
+    /**
39
+     * @var string Default action is actionInit();
40
+     */
41
+    public $defaultAction = 'init';
42 42
 	
43
-	/**
44
-	 * @var array The default repos from luyadev
45
-	 */
43
+    /**
44
+     * @var array The default repos from luyadev
45
+     */
46 46
     public $repos = [
47 47
         'luya',
48 48
         'luya-module-admin',
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function actionClone($repo = null, $vendor = null)
168 168
     {
169
-    	if (empty($repo)) {
170
-    		$repo = $this->prompt("Enter the name of the repo you like to clone (e.g. luya-module-news)");
171
-    	}
169
+        if (empty($repo)) {
170
+            $repo = $this->prompt("Enter the name of the repo you like to clone (e.g. luya-module-news)");
171
+        }
172 172
     	
173
-    	if (empty($vendor)) {
174
-    		$vendor = $this->prompt("Enter the username/vendor for this repo (e.g. luyadev)");
175
-    	}
173
+        if (empty($vendor)) {
174
+            $vendor = $this->prompt("Enter the username/vendor for this repo (e.g. luyadev)");
175
+        }
176 176
     	
177
-    	return $this->cloneRepo($repo, $this->getCloneUrlBasedOnType($repo, $vendor), $this->getFilesystemRepoPath($repo), $vendor);
177
+        return $this->cloneRepo($repo, $this->getCloneUrlBasedOnType($repo, $vendor), $this->getFilesystemRepoPath($repo), $vendor);
178 178
     }
179 179
     
180 180
     private $_gitWrapper;
@@ -184,38 +184,38 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function getGitWrapper()
186 186
     {
187
-    	if ($this->_gitWrapper === null) {
188
-    		$this->_gitWrapper = new GitWrapper();
189
-    		$this->_gitWrapper->setTimeout(300);
190
-    	}
187
+        if ($this->_gitWrapper === null) {
188
+            $this->_gitWrapper = new GitWrapper();
189
+            $this->_gitWrapper->setTimeout(300);
190
+        }
191 191
     
192
-    	return $this->_gitWrapper;
192
+        return $this->_gitWrapper;
193 193
     }
194 194
     
195 195
     private function summaryItem($repo, $isFork, $exists)
196 196
     {
197
-    	return [$repo, $exists, $isFork];
197
+        return [$repo, $exists, $isFork];
198 198
     }
199 199
     
200 200
     private function getFilesystemRepoPath($repo)
201 201
     {
202
-    	return 'repos' . DIRECTORY_SEPARATOR . $repo;
202
+        return 'repos' . DIRECTORY_SEPARATOR . $repo;
203 203
     }
204 204
     
205 205
     private function forkExists($username, $repo)
206 206
     {
207
-    	return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess();
207
+        return (new Curl())->get('https://api.github.com/repos/'.$username.'/'.$repo)->isSuccess();
208 208
     }
209 209
     
210 210
     private function markdown($text, $paragraph = false)
211 211
     {
212
-    	$parser = new Markdown();
212
+        $parser = new Markdown();
213 213
     
214
-    	if ($paragraph) {
215
-    		return $parser->parseParagraph($text);
216
-    	}
214
+        if ($paragraph) {
215
+            return $parser->parseParagraph($text);
216
+        }
217 217
     
218
-    	return $parser->parse($text);
218
+        return $parser->parse($text);
219 219
     }
220 220
     
221 221
     /**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     private function getCloneUrlBasedOnType($repo, $username)
229 229
     {
230
-    	return ($this->getConfig(self::CONFIG_VAR_CLONETYPE) == 'ssh') ? "[email protected]:{$username}/{$repo}.git" : "https://github.com/{$username}/{$repo}.git";
230
+        return ($this->getConfig(self::CONFIG_VAR_CLONETYPE) == 'ssh') ? "[email protected]:{$username}/{$repo}.git" : "https://github.com/{$username}/{$repo}.git";
231 231
     }
232 232
     
233 233
     /**
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
      */
241 241
     private function cloneRepo($repo, $cloneUrl, $newRepoHome, $upstreamUsername)
242 242
     {
243
-    	$this->outputSuccess("{$repo}: cloning ...");
244
-    	$this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome);
245
-    	if (!empty($upstreamUsername)) {
246
-    		$this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git',  $newRepoHome);
247
-    		$this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git");
248
-    	}
249
-    	$this->outputSuccess("{$repo}: ✔ complete");
243
+        $this->outputSuccess("{$repo}: cloning ...");
244
+        $this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome);
245
+        if (!empty($upstreamUsername)) {
246
+            $this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git',  $newRepoHome);
247
+            $this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git");
248
+        }
249
+        $this->outputSuccess("{$repo}: ✔ complete");
250 250
     }
251 251
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         // generate summary overview
89 89
         foreach ($this->repos as $repo) {
90 90
             $newRepoHome = $this->getFilesystemRepoPath($repo);
91
-            if (file_exists($newRepoHome . DIRECTORY_SEPARATOR . '.git')) {
91
+            if (file_exists($newRepoHome.DIRECTORY_SEPARATOR.'.git')) {
92 92
                 $summary[] = $this->summaryItem($repo, false, true);
93 93
             } elseif ($this->forkExists($username, $repo)) {
94 94
                 $summary[] = $this->summaryItem($repo, true, false);
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
         $wrapper = new GitWrapper();
148 148
         
149 149
         foreach ($this->repos as $repo) {
150
-            $wrapper->git('checkout master',  'repos' . DIRECTORY_SEPARATOR . $repo);
150
+            $wrapper->git('checkout master', 'repos'.DIRECTORY_SEPARATOR.$repo);
151 151
             $this->outputInfo("{$repo}: checkout master ✔");
152 152
             
153
-            $wrapper->git('fetch upstream',  'repos' . DIRECTORY_SEPARATOR . $repo);
153
+            $wrapper->git('fetch upstream', 'repos'.DIRECTORY_SEPARATOR.$repo);
154 154
             $this->outputInfo("{$repo}: fetch upstream ✔");
155 155
             
156
-            $wrapper->git('rebase upstream/master master',  'repos' . DIRECTORY_SEPARATOR . $repo);
156
+            $wrapper->git('rebase upstream/master master', 'repos'.DIRECTORY_SEPARATOR.$repo);
157 157
             $this->outputInfo("{$repo}: rebase master ✔");
158 158
         }
159 159
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     
200 200
     private function getFilesystemRepoPath($repo)
201 201
     {
202
-    	return 'repos' . DIRECTORY_SEPARATOR . $repo;
202
+    	return 'repos'.DIRECTORY_SEPARATOR.$repo;
203 203
     }
204 204
     
205 205
     private function forkExists($username, $repo)
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     	$this->outputSuccess("{$repo}: cloning ...");
244 244
     	$this->getGitWrapper()->cloneRepository($cloneUrl, $newRepoHome);
245 245
     	if (!empty($upstreamUsername)) {
246
-    		$this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git',  $newRepoHome);
246
+    		$this->getGitWrapper()->git('remote add upstream https://github.com/'.$upstreamUsername.'/'.$repo.'.git', $newRepoHome);
247 247
     		$this->outputInfo("Configure upstream https://github.com/{$upstreamUsername}/{$repo}.git");
248 248
     	}
249 249
     	$this->outputSuccess("{$repo}: ✔ complete");
Please login to merge, or discard this patch.