Use correct Git ref spec when sub_directory is specified. (#3138)

* Use correct Git ref spec when `sub_directory` is specified.

The bug is described in detail in issue #3137.

* change variable name for sub-directory target (as requested in PR)
This commit is contained in:
Marcus Jaschen 2022-05-24 21:36:50 +02:00 committed by GitHub
parent 764d3cd0b8
commit fe3874370b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,8 +72,10 @@ task('deploy:update_code', function () {
$git = get('bin/git'); $git = get('bin/git');
$repository = get('repository'); $repository = get('repository');
$target = get('target'); $target = get('target');
$targetWithDir = $target;
if (!empty(get('sub_directory'))) { if (!empty(get('sub_directory'))) {
$target = "$target:{{sub_directory}}"; $targetWithDir .= ':{{sub_directory}}';
} }
$bare = parse('{{deploy_path}}/.dep/repo'); $bare = parse('{{deploy_path}}/.dep/repo');
@ -100,7 +102,7 @@ task('deploy:update_code', function () {
// Copy to release_path. // Copy to release_path.
if (get('update_code_strategy') === 'archive') { if (get('update_code_strategy') === 'archive') {
run("$git archive $target | tar -x -f - -C {{release_path}} 2>&1"); run("$git archive $targetWithDir | tar -x -f - -C {{release_path}} 2>&1");
} else if (get('update_code_strategy') === 'clone') { } else if (get('update_code_strategy') === 'clone') {
cd('{{release_path}}'); cd('{{release_path}}');
run("$git clone -l $bare ."); run("$git clone -l $bare .");