Skip to content

Commit

Permalink
Merge pull request #158 from aik099/auto-deploy-feat
Browse files Browse the repository at this point in the history
Converted "--deploy" option of the `commit`/`update` commands into "--auto-deploy yes/no" option
  • Loading branch information
aik099 authored Aug 20, 2024
2 parents 0099d23 + 3949b85 commit 687a927
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 19 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Display non-executed SVN command (results pulled from the cache) in the verbose mode.
- Display non-executed SVN command (results pulled from the cache) results in the debug mode.
- Added the `deploy` command, that will execute, specified in the config, local/remote commands.
- Added `--deploy` option to the `commit` command, that will perform a remote deployment after a successful commit (#131).
- Added `--deploy` option to the `update` command, that will perform a local deployment after a successful update.
- Added `commit.auto-deploy` config setting (enabled by default), that allows to tell if a remote deployment should happen after successful commit (#131).
- Added `--auto-deploy` option to `commit` command to allow overriding behavior imposed by `commit.auto-deploy` config setting.
- Added `update.auto-deploy` config setting (enabled by default), that allows to tell if a local deployment should happen after successful update.
- Added `--auto-deploy` option to `update` command to allow overriding behavior imposed by `update.auto-deploy` config setting.

### Changed
- The `config` command groups configuration settings by a command.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ The command sends changes from your working copy to the repository.

* `--cl` - Operate only on members of selected changelist
* `--merge-template=MERGE-TEMPLATE` Use alternative merge template for this commit
* `-d`, `--deploy` - Perform remote deployment after a successful commit
* `--auto-deploy=AUTO-DEPLOY` - Automatically perform remote deployment on successful commit, e.g. `yes` or `no`

#### Configuration settings

Expand Down Expand Up @@ -563,7 +563,7 @@ Bring changes from the repository into the working copy.

* `-r`, `--revision=REVISION` - Update working copy to specified revision, e.g. `NUMBER`, `{DATE}`, `HEAD`, `BASE`, `COMMITTED`, `PREV`
* `--ignore-externals` - Ignore externals definitions
* `-d`, `--deploy` - Perform local deployment after a successful update
* `--auto-deploy=AUTO-DEPLOY` - Automatically perform local deployment on successful update, e.g. `yes` or `no`

#### Examples

Expand Down
36 changes: 28 additions & 8 deletions src/SVNBuddy/Command/CommitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class CommitCommand extends AbstractCommand implements IConfigAwareCommand

const SETTING_COMMIT_MERGE_TEMPLATE = 'commit.merge-template';

const SETTING_COMMIT_AUTO_DEPLOY = 'commit.auto-deploy';

const STOP_LINE = '--This line, and those below, will be ignored--';

/**
Expand Down Expand Up @@ -90,10 +92,10 @@ protected function configure()
'Use alternative merge template for this commit'
)
->addOption(
'deploy',
'd',
InputOption::VALUE_NONE,
'Perform remote deployment after a successful commit'
'auto-deploy',
null,
InputOption::VALUE_REQUIRED,
'Automatically perform remote deployment on successful commit, e.g. <comment>yes</comment> or <comment>no</comment>'
);

parent::configure();
Expand All @@ -115,6 +117,10 @@ public function completeOptionValues($optionName, CompletionContext $context)
return $this->getMergeTemplateNames();
}

if ( $optionName === 'auto-deploy' ) {
return array('yes', 'no');
}

return $ret;
}

Expand Down Expand Up @@ -222,13 +228,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function deploy()
{
if ( !$this->io->getOption('deploy') ) {
return false;
$auto_deploy = $this->io->getOption('auto-deploy');

if ( $auto_deploy !== null ) {
$auto_deploy = $auto_deploy === 'yes';
}
else {
$auto_deploy = (boolean)$this->getSetting(self::SETTING_COMMIT_AUTO_DEPLOY);
}

if ( $auto_deploy ) {
$this->runOtherCommand('deploy', array('--remote' => true));

$this->runOtherCommand('deploy', array('--remote' => true));
return true;
}

return true;
return false;
}

/**
Expand Down Expand Up @@ -311,6 +326,11 @@ public function getConfigSettings()
$merge_template_names,
reset($merge_template_names)
),
new ChoiceConfigSetting(
self::SETTING_COMMIT_AUTO_DEPLOY,
array(1 => 'Yes', 0 => 'No'),
1
),
);
}

Expand Down
75 changes: 68 additions & 7 deletions src/SVNBuddy/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@
namespace ConsoleHelpers\SVNBuddy\Command;


use ConsoleHelpers\SVNBuddy\Config\AbstractConfigSetting;
use ConsoleHelpers\SVNBuddy\Config\ChoiceConfigSetting;
use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyConflictTracker;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class UpdateCommand extends AbstractCommand implements IAggregatorAwareCommand
class UpdateCommand extends AbstractCommand implements IAggregatorAwareCommand, IConfigAwareCommand
{

const SETTING_UPDATE_AUTO_DEPLOY = 'update.auto-deploy';

/**
* Working copy conflict tracker.
*
Expand Down Expand Up @@ -69,15 +74,34 @@ protected function configure()
'Ignore externals definitions'
)
->addOption(
'deploy',
'd',
InputOption::VALUE_NONE,
'Perform local deployment after a successful update'
'auto-deploy',
null,
InputOption::VALUE_REQUIRED,
'Automatically perform local deployment on successful update, e.g. <comment>yes</comment> or <comment>no</comment>'
);

parent::configure();
}

/**
* Return possible values for the named option
*
* @param string $optionName Option name.
* @param CompletionContext $context Completion context.
*
* @return array
*/
public function completeOptionValues($optionName, CompletionContext $context)
{
$ret = parent::completeOptionValues($optionName, $context);

if ( $optionName === 'auto-deploy' ) {
return array('yes', 'no');
}

return $ret;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -115,9 +139,30 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->io->writeln('<info>Done</info>');

if ( $this->io->getOption('deploy') ) {
$this->runOtherCommand('deploy', array('--local' => true));
$this->deploy();
}

/**
* Performs a deploy.
*
* @return void
*/
protected function deploy()
{
$auto_deploy = $this->io->getOption('auto-deploy');

if ( $auto_deploy !== null ) {
$auto_deploy = $auto_deploy === 'yes';
}
else {
$auto_deploy = (boolean)$this->getSetting(self::SETTING_UPDATE_AUTO_DEPLOY);
}

if ( !$auto_deploy ) {
return;
}

$this->runOtherCommand('deploy', array('--local' => true));
}

/**
Expand All @@ -130,4 +175,20 @@ public function getAggregatedOptions()
return array('ignore-externals');
}

/**
* Returns list of config settings.
*
* @return AbstractConfigSetting[]
*/
public function getConfigSettings()
{
return array(
new ChoiceConfigSetting(
self::SETTING_UPDATE_AUTO_DEPLOY,
array(1 => 'Yes', 0 => 'No'),
1
),
);
}

}

0 comments on commit 687a927

Please sign in to comment.