mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-28 09:42:40 +01:00
Deprecate "PhutilExecPassthru->execute()" in favor of "resolve()"
Summary: Fixes T13660. See also D21703. The most desirable modern API here is "resolve()", so deprecate the similar "execute()". Test Plan: - Grepped for callsites. - Ran `arc patch --trace` in a Git working copy and saw the updated "git apply" in the trace output. - Used this test script (changing the method and the command invoked) to confirm that success and error behavior is identical in "resolve()" and "execute()", except that "execute()" now emits a deprecation warning: ``` <?php require_once 'support/init/init-script.php'; $err = id(new PhutilExecPassthru('lsx'))->execute(); var_dump($err); ``` Reviewers: cspeckmim Reviewed By: cspeckmim Maniphest Tasks: T13660 Differential Revision: https://secure.phabricator.com/D21705
This commit is contained in:
parent
ac365c3ee5
commit
8bb7d58890
3 changed files with 14 additions and 6 deletions
|
@ -10,8 +10,8 @@
|
||||||
* This is primarily useful for executing things like `$EDITOR` from command
|
* This is primarily useful for executing things like `$EDITOR` from command
|
||||||
* line scripts.
|
* line scripts.
|
||||||
*
|
*
|
||||||
* $exec = new PhutilExecPassthru('ls %s', $dir);
|
* $exec = new PhutilExecPassthru('nano -- %s', $filename);
|
||||||
* $err = $exec->execute();
|
* $err = $exec->resolve();
|
||||||
*
|
*
|
||||||
* You can set the current working directory for the command with
|
* You can set the current working directory for the command with
|
||||||
* @{method:setCWD}, and set the environment with @{method:setEnv}.
|
* @{method:setCWD}, and set the environment with @{method:setEnv}.
|
||||||
|
@ -30,6 +30,14 @@ final class PhutilExecPassthru extends PhutilExecutableFuture {
|
||||||
/* -( Executing Passthru Commands )---------------------------------------- */
|
/* -( Executing Passthru Commands )---------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function execute() {
|
||||||
|
phlog(
|
||||||
|
pht(
|
||||||
|
'The "execute()" method of "PhutilExecPassthru" is deprecated and '.
|
||||||
|
'calls should be replaced with "resolve()". See T13660.'));
|
||||||
|
return $this->resolve();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute this command.
|
* Execute this command.
|
||||||
*
|
*
|
||||||
|
@ -37,7 +45,7 @@ final class PhutilExecPassthru extends PhutilExecutableFuture {
|
||||||
*
|
*
|
||||||
* @task command
|
* @task command
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
private function executeCommand() {
|
||||||
$command = $this->getCommand();
|
$command = $this->getCommand();
|
||||||
|
|
||||||
$is_write = ($this->stdinData !== null);
|
$is_write = ($this->stdinData !== null);
|
||||||
|
@ -116,7 +124,7 @@ final class PhutilExecPassthru extends PhutilExecutableFuture {
|
||||||
// make it easier to share code with ExecFuture.
|
// make it easier to share code with ExecFuture.
|
||||||
|
|
||||||
if (!$this->hasResult()) {
|
if (!$this->hasResult()) {
|
||||||
$result = $this->execute();
|
$result = $this->executeCommand();
|
||||||
$this->setResult($result);
|
$this->setResult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class ExecPassthruTestCase extends PhutilTestCase {
|
||||||
$bin = $this->getSupportExecutable('exit');
|
$bin = $this->getSupportExecutable('exit');
|
||||||
|
|
||||||
$exec = new PhutilExecPassthru('php -f %R', $bin);
|
$exec = new PhutilExecPassthru('php -f %R', $bin);
|
||||||
$err = $exec->execute();
|
$err = $exec->resolve();
|
||||||
$this->assertEqual(0, $err);
|
$this->assertEqual(0, $err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,7 +707,7 @@ EOTEXT
|
||||||
'git apply --whitespace nowarn --index --reject -- %s',
|
'git apply --whitespace nowarn --index --reject -- %s',
|
||||||
$patchfile);
|
$patchfile);
|
||||||
$passthru->setCWD($repository_api->getPath());
|
$passthru->setCWD($repository_api->getPath());
|
||||||
$err = $passthru->execute();
|
$err = $passthru->resolve();
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
|
|
Loading…
Reference in a new issue