@@ -192,6 +192,10 @@ discard block |
||
| 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 |
||
| 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(); |
@@ -31,18 +31,18 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |