Skip to content

Commit

Permalink
Improving the upgrade shell by adding more renaming rules and making …
Browse files Browse the repository at this point in the history
…it more robust in case insensitive systems
  • Loading branch information
lorenzo committed Oct 19, 2011
1 parent d1be66f commit d666d61
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -141,12 +141,15 @@ public function locations() {
$this->_files = array();
chdir($cwd);
}

$this->_moveViewFiles();

$moves = array(
'config' => 'Config',
'Config' . DS . 'schema' => 'Config' . DS . 'Schema',
'libs' => 'Lib',
'tests' => 'Test',
'views' => 'View',
'models' => 'Model',
'Model' . DS . 'behaviors' => 'Model' . DS . 'Behavior',
'Model' . DS . 'datasources' => 'Model' . DS . 'Datasource',
'Test' . DS . 'cases' => 'Test' . DS . 'Case',
'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
Expand All @@ -156,26 +159,28 @@ public function locations() {
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) {
if ($this->params['git']) {
exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new));
exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
} else {
$Folder = new Folder($old);
$Folder->move($new);
}
}
}
}
$this->_moveViewFiles();
$sourceDirs = array(
'.' => array('recursive' => false),
'Console',
'Controller',
'controllers',
'Controller',
'Lib' => array('checkFolder' => false),
'Model',
'models',
'Test' => array('regex' => '@class (\S*Test) extends CakeTestCase@'),
'Model',
'tests',
'View',
'Test' => array('regex' => '@class (\S*Test) extends CakeTestCase@'),
'views',
'View',
'vendors/shells',
);

Expand Down Expand Up @@ -515,23 +520,27 @@ public function components() {
* @return void
*/
protected function _moveViewFiles() {
if (!is_dir('views')) {
if (!is_dir('View')) {
return;
}

$dirs = scandir('views');
$dirs = scandir('View');
foreach ($dirs as $old) {
if (!is_dir('views' . DS . $old) || $old === '.' || $old === '..') {
if (!is_dir('View' . DS . $old) || $old === '.' || $old === '..') {
continue;
}

$new = 'View' . DS . Inflector::camelize($old);
$old = 'views' . DS . $old;
$old = 'View' . DS . $old;
if ($new == $old) {
continue;
}

$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) {
if ($this->params['git']) {
exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new));
exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($old . '__'));
exec('git mv -f ' . escapeshellarg($old . '__') . ' ' . escapeshellarg($new));
} else {
$Folder = new Folder($old);
$Folder->move($new);
Expand Down Expand Up @@ -620,7 +629,8 @@ protected function _movePhpFiles($path, $options) {
$this->out(__d('cake_console', 'Moving %s to %s', $file, $new), 1, Shell::VERBOSE);
if (!$this->params['dry-run']) {
if ($this->params['git']) {
exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($new));
exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($file . '__'));
exec('git mv -f ' . escapeshellarg($file. '__') . ' ' . escapeshellarg($new));
} else {
rename($file, $new);
}
Expand Down

0 comments on commit d666d61

Please sign in to comment.