diff --git a/recipe/deploy/update_code.php b/recipe/deploy/update_code.php index 5ec662179..efff557f9 100644 --- a/recipe/deploy/update_code.php +++ b/recipe/deploy/update_code.php @@ -81,11 +81,12 @@ if ($strategy === 'local_archive') { $gitRoot = runLocally("git rev-parse --show-toplevel"); - runLocally("git -C " . quote($gitRoot) . " archive $targetWithDir -o archive.tar"); - upload("$gitRoot/archive.tar", '{{release_path}}/archive.tar'); + $archive = tempnam(sys_get_temp_dir(), 'deployer_archive_'); + runLocally("git -C " . quote($gitRoot) . " archive $targetWithDir -o " . quote($archive)); + upload($archive, '{{release_path}}/archive.tar'); run("tar -xf {{release_path}}/archive.tar -C {{release_path}}"); run("rm {{release_path}}/archive.tar"); - unlink("$gitRoot/archive.tar"); + unlink($archive); $rev = quote(runLocally("git rev-list $target -1")); } else { diff --git a/tests/spec/LocalArchiveTest.php b/tests/spec/LocalArchiveTest.php new file mode 100644 index 000000000..31ca85404 --- /dev/null +++ b/tests/spec/LocalArchiveTest.php @@ -0,0 +1,46 @@ +init(self::RECIPE); + $this->tester->run([ + 'deploy', + 'selector' => 'all', + '-f' => self::RECIPE, + ], [ + 'verbosity' => Output::VERBOSITY_VERBOSE, + ]); + + $display = $this->tester->getDisplay(); + self::assertEquals(0, $this->tester->getStatusCode(), $display); + + foreach ($this->deployer->hosts as $host) { + $deployPath = $host->get('deploy_path'); + self::assertFileExists($deployPath . '/current/README.md', $display); + } + + $gitRoot = trim((string) shell_exec('git rev-parse --show-toplevel')); + self::assertFileDoesNotExist($gitRoot . '/archive.tar'); + } +} diff --git a/tests/spec/recipe/local_archive.php b/tests/spec/recipe/local_archive.php new file mode 100644 index 000000000..3ebab2516 --- /dev/null +++ b/tests/spec/recipe/local_archive.php @@ -0,0 +1,14 @@ +