-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added --hook option #934
Added --hook option #934
Conversation
Tests are failing, though I don't understand why. |
I think test failing in parallel tests. Try fix it myself. |
@peterjaap also i think test for this options will be cool. |
The test actually revealed a bug in the code, heh, who would've thought. All checks passing! |
What about renaming to --no-hooks? |
Yes, perfect.
Op do 19 jan. 2017 om 05:41 schreef Anton Medvedev <[email protected]
…:
What about renaming to --no-hooks?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#934 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAaVAKfSw4MqZxt0FBqdVL2XnUQHPadgks5rTumEgaJpZM4LUsuX>
.
|
@@ -62,6 +62,13 @@ protected function execute(Input $input, Output $output) | |||
$stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null; | |||
|
|||
$tasks = $this->deployer->getScriptManager()->getTasks($this->getName(), $stage); | |||
|
|||
if (!$input->getOption('hooks') || $input->getOption('hooks') === 'false') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what about group task? Them will not be working like this :/
@@ -118,6 +118,7 @@ | |||
option('tag', null, InputOption::VALUE_OPTIONAL, 'Tag to deploy'); | |||
option('revision', null, InputOption::VALUE_OPTIONAL, 'Revision to deploy'); | |||
option('branch', null, InputOption::VALUE_OPTIONAL, 'Branch to deploy'); | |||
option('hooks', null, InputOption::VALUE_OPTIONAL, 'Set to false to skip after/before hooks', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change to no-hooks
. Also please set $mode = InputOption::VALUE_NONE and remove default value. Then in TaskCommand:66 you can use just one simple condition if ($input->getOption('no-hooks')) {
.
if (!$input->getOption('hooks') || $input->getOption('hooks') === 'false') { | ||
$tasks = array_filter($tasks, function ($task) { | ||
return $this->getName() == $task->getName(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterjaap I guess you should implement ScriptManager::setHooksEnabled(true|false)
and use the $isHooksEnabled
flag in ScriptManager::getTasks()
method. It will work both for single and group tasks.
Also nice to have tests for that. Check test/src/FunctionsTest.php with pretty same ones.
Peter, could you do that? Do you have a free time?
Closing as duplicate of #1061 (this pr fixes group scripts) |
Add `--no-hooks` option for running commands without `before()` and `after()` (#934)
Added --hook option to disable running other tasks than the one specified
I wanted a way to run certain tasks without having the before/after hooks set in deploy.php to be run, because some of those tasks might assume we are in a deploy context while maybe we're not.
We can now do;
dep custom:command:here staging --hooks false
While we have
So not to run
another:command:after:custom
oranother:command:before:custom
but still runcustom:command:here
.