Skip to content

Commit

Permalink
added --useHttp option to dev command
Browse files Browse the repository at this point in the history
allows to clone repos using HTTP only, not SSH

issue yiisoft#3267
  • Loading branch information
cebe committed May 27, 2015
1 parent 47bcd02 commit 9c10f17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 22 additions & 2 deletions build/controllers/DevController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class DevController extends Controller
{
public $defaultAction = 'all';

/**
* @var bool whether to use HTTP when cloning github repositories
*/
public $useHttp = false;

public $apps = [
'basic' => '[email protected]:yiisoft/yii2-app-basic.git',
'advanced' => '[email protected]:yiisoft/yii2-app-advanced.git',
Expand Down Expand Up @@ -63,14 +68,14 @@ public function actionAll()
}

foreach($this->extensions as $ext => $repo) {
$ret = $this->actionExt($ext, $repo);
$ret = $this->actionExt($ext);
if ($ret !== 0) {
return $ret;
}
}

foreach($this->apps as $app => $repo) {
$ret = $this->actionApp($app, $repo);
$ret = $this->actionApp($app);
if ($ret !== 0) {
return $ret;
}
Expand Down Expand Up @@ -136,6 +141,9 @@ public function actionApp($app, $repo = null)
if (empty($repo)) {
if (isset($this->apps[$app])) {
$repo = $this->apps[$app];
if ($this->useHttp) {
$repo = str_replace('[email protected]:', 'https://github.com/', $repo);
}
} else {
$this->stderr("Repo argument is required for app '$app'.\n", Console::FG_RED);
return 1;
Expand Down Expand Up @@ -182,6 +190,9 @@ public function actionExt($extension, $repo = null)
if (empty($repo)) {
if (isset($this->extensions[$extension])) {
$repo = $this->extensions[$extension];
if ($this->useHttp) {
$repo = str_replace('[email protected]:', 'https://github.com/', $repo);
}
} else {
$this->stderr("Repo argument is required for extension '$extension'.\n", Console::FG_RED);
return 1;
Expand Down Expand Up @@ -212,6 +223,15 @@ public function actionExt($extension, $repo = null)
return 0;
}

public function options($actionID)
{
$options = parent::options($actionID);
if (in_array($actionID, ['ext', 'app', 'all'])) {
$options[] = 'useHttp';
}
return $options;
}


protected function cleanupVendorDir($dir)
{
Expand Down
6 changes: 6 additions & 0 deletions docs/internals/git-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ The following steps are not necessary if you want to work only on translations o

This command will also be used to update dependencies, it runs `composer update` internally.

> Note: The default git repository Urls clone from github via SSH, you may add the `--useHttp` flag to the `build` command
> to use HTTPs instead.
**Now you have a working playground for hacking on Yii 2.**

The following steps are optional.
Expand Down Expand Up @@ -72,6 +75,9 @@ normally do e.g. add `"yiisoft/yii2-redis": "*"` to the `require` section of the
Running `php build/build dev/app basic` will install the extension and its dependecies and create
a symlink to `extensions/redis` so you are not working in the composer vendor dir but in the yii2 repository directly.

> Note: The default git repository Urls clone from github via SSH, you may add the `--useHttp` flag to the `build` command
> to use HTTPs instead.

Working on bugs and features
----------------------------
Expand Down

0 comments on commit 9c10f17

Please sign in to comment.