1
0
Fork 0
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:
epriestley 2021-07-21 10:07:24 -07:00
parent ac365c3ee5
commit 8bb7d58890
3 changed files with 14 additions and 6 deletions

View file

@ -10,8 +10,8 @@
* This is primarily useful for executing things like `$EDITOR` from command
* line scripts.
*
* $exec = new PhutilExecPassthru('ls %s', $dir);
* $err = $exec->execute();
* $exec = new PhutilExecPassthru('nano -- %s', $filename);
* $err = $exec->resolve();
*
* You can set the current working directory for the command with
* @{method:setCWD}, and set the environment with @{method:setEnv}.
@ -30,6 +30,14 @@ final class PhutilExecPassthru extends PhutilExecutableFuture {
/* -( 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.
*
@ -37,7 +45,7 @@ final class PhutilExecPassthru extends PhutilExecutableFuture {
*
* @task command
*/
public function execute() {
private function executeCommand() {
$command = $this->getCommand();
$is_write = ($this->stdinData !== null);
@ -116,7 +124,7 @@ final class PhutilExecPassthru extends PhutilExecutableFuture {
// make it easier to share code with ExecFuture.
if (!$this->hasResult()) {
$result = $this->execute();
$result = $this->executeCommand();
$this->setResult($result);
}

View file

@ -11,7 +11,7 @@ final class ExecPassthruTestCase extends PhutilTestCase {
$bin = $this->getSupportExecutable('exit');
$exec = new PhutilExecPassthru('php -f %R', $bin);
$err = $exec->execute();
$err = $exec->resolve();
$this->assertEqual(0, $err);
}

View file

@ -707,7 +707,7 @@ EOTEXT
'git apply --whitespace nowarn --index --reject -- %s',
$patchfile);
$passthru->setCWD($repository_api->getPath());
$err = $passthru->execute();
$err = $passthru->resolve();
if ($err) {
echo phutil_console_format(