deployer: get('branch') returns incorrect branch when run within a locally run task
Describe the bug
If you have set a branch within a stage by using ->set('branch', 'develop')
, the branch is ignored completely for tasks set to run locally.
To reproduce
- Copy the contents of
deploy.php
below. - Run
dep deploy staging
.
Actual behavior ➤ Executing task branch:name Branch develop ➤ Executing task branch:localname Branch master
Expected behavior ➤ Executing task branch:name Branch develop ➤ Executing task branch:localname Branch develop
Environment
- Deployer version: v6.8.0
- PHP version: v7.3.20
- Deployment target(s) OS: CentOS 7
Content of deploy.php
<?php
namespace Deployer;
require 'recipe/common.php';
set('allow_anonymous_stats', false);
set('branch', 'master'); // Default branch
host('staging')
->set('branch', 'develop')
->set('deploy_path', '/var/www/html');
task('branch:name', function() {
writeln('Branch ' . get('branch'));
});
task('branch:localname', function() {
writeln('Branch ' . get('branch'));
})->local();
desc('Deploy your branch bug report.');
task('deploy', [
'branch:name',
'branch:localname'
]);
Output log with enabled option for verbose output -vvv
$ dep deploy staging -vvv
➤ Executing task branch:name
Branch develop
• done on [staging]
✔ Ok [0ms]
➤ Executing task branch:localname
Branch master
✔ Ok [0ms]
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (15 by maintainers)
Yes, I can confirm that this is working now! Given the following host and task:
Result with beta 13:
Result with the latest beta 19 (at least 14):
@antonmedv , thanks a lot!