Skip to content

Commit

Permalink
Split option --install-provisional-version into two commands. --insta…
Browse files Browse the repository at this point in the history
…ll-provisional-version becomes a bool and new option --provisional-version accepts a string.
  • Loading branch information
joegreen88 committed Jan 16, 2016
1 parent 7a77023 commit 86bfe17
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/Smrtr/MysqlVersionControl/UpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ protected function configure()
->addOption(
'install-provisional-version',
null,
InputOption::VALUE_OPTIONAL,
'Install a provisional version which may still be in development and is not final. '.PHP_EOL.
'The provisional version is in a dir named \''.self::DEFAULT_PROVISIONAL_VERSION_NAME.'\' by default; '.
PHP_EOL.'provide a value for this option to override the dirname.'
InputOption::VALUE_NONE,
'Install a provisional version which may still be in development and is not final.'
)
->addOption(
'provisional-version',
null,
InputOption::VALUE_REQUIRED,
'The name of the provisional version',
static::DEFAULT_PROVISIONAL_VERSION_NAME
)
;
}
Expand Down Expand Up @@ -99,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Installing version control...');

$result = $buildConf->prepare(
"CREATE TABLE `db_config`
"CREATE TABLE `db_config`
(
`key` VARCHAR(50) COLLATE 'utf8_general_ci' NOT NULL,
`value` TEXT,
Expand Down Expand Up @@ -182,20 +187,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

// Look for a provisional version?
$provisionalVersion = $input->getOption('install-provisional-version');
if ($provisionalVersion) {

if (!is_string($provisionalVersion)) {
$provisionalVersion = self::DEFAULT_PROVISIONAL_VERSION_NAME;
}
$provisionalVersion = null;
if ($input->getOption('install-provisional-version')) {

$provisionalVersion = $input->getOption('provisional-version');
$output->writeln('Provisional version: '.$provisionalVersion);

$path = $versionsPath.DIRECTORY_SEPARATOR.$provisionalVersion;
if (is_readable($path) && is_dir($path)) {

foreach ($filesToLookFor as $file) {
if (is_readable($file.DIRECTORY_SEPARATOR.$file) && is_file($path.DIRECTORY_SEPARATOR.$file)) {
if (is_readable($path.DIRECTORY_SEPARATOR.$file) && is_file($path.DIRECTORY_SEPARATOR.$file)) {
$stack[$provisionalVersion][$file] = $path.DIRECTORY_SEPARATOR.$file;
}
}
Expand Down Expand Up @@ -275,7 +277,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

if ($result) {
if ($result && is_int($version)) {
$result = $buildConf->query(
"REPLACE INTO `db_config` (`key`, `value`, `updated_at`) VALUES ('version', $version, now())"
)->execute();
Expand Down

0 comments on commit 86bfe17

Please sign in to comment.