]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Write ARCANIST into the environment while running arc
authorepriestley <git@epriestley.com>
Thu, 10 Oct 2013 13:18:37 +0000 (06:18 -0700)
committerepriestley <git@epriestley.com>
Thu, 10 Oct 2013 13:18:37 +0000 (06:18 -0700)
Summary:
Addresses a request to let Git commit hooks react differently when run via `arc`. While executing an `arc` command, write ARCANIST into the environment.

(I wrote the actual command as the value since it seemed like it could plausibly be more useful than `true` or `1`.)

Test Plan: Added `pre-commit` to `.git/hooks` which did `echo $ARCANIST`, verified the envvar was accessible when running via arc.

Reviewers: btrahan, frgtn

Reviewed By: frgtn

CC: aran
Differential Revision: https://secure.phabricator.com/D7281

scripts/arcanist.php

index 63aaf9395906babc5c3f5d54595fbb5a5257434c..7b0088e9922f8572dcc1efb35d62d867d23146e2 100755 (executable)
@@ -150,6 +150,11 @@ try {
   $workflow->setWorkingDirectory($working_directory);
   $workflow->parseArguments($args);
 
+  // Write the command into the environment so that scripts (for example, local
+  // Git commit hooks) can detect that they're being run via `arc` and change
+  // their behaviors.
+  putenv('ARCANIST='.$command);
+
   if ($force_conduit_version) {
     $workflow->forceConduitVersion($force_conduit_version);
   }