1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-26 14:38:19 +01:00
phorge-phorge/src/docs/userguide/arcanist_hooks.diviner
epriestley 99b9ceb6d7 Fix arcanist documentation to include "set -e" in example SVN hooks
Summary: "set -e" causes the script to exit if any command returns nonzero.
Without it, we incorrectly discard the failure code. At Facebook everything runs
in "set -e" or some equivalent so I never picked this up in testing.

Test Plan:
Added the hook to my svn local, it blocked bad commits and allowed good ones.

  >>> orbital:~/devtools/svnroot $ svn commit -m "quaa"
  Sending        test.php
  Transmitting file data .svn: Commit failed (details follow):
  svn: Commit blocked by pre-commit hook (exit code 1) with output:

  LINT ERRORS

  This changeset has lint errors. You must fix all lint errors before you can
  commit.

  You can add '@bypass-lint' to your commit message to disable lint checks for
  this commit, or '@nolint' to the file with errors to disable lint for that
  file.

  >>> Lint for test.php:

     Error  (XHP1) PHP Syntax Error!
      This file contains a syntax error: XHPAST Parse Error: syntax error,
      unexpected '}' on line 1

      >>>        1 <?php asdddddd;!}}

Reviewers: svemir, jungejason, tuomaspelkonen, aran

Reviewed By: svemir

CC: aran, svemir, epriestley

Differential Revision: 864
2011-08-26 11:51:38 -07:00

41 lines
1.6 KiB
Text

@title Arcanist User Guide: Repository Hooks
@group userguide
Describes how to set up Arcanist as an SVN pre-commit hook.
NOTE: This whole thing might be a little shaky and take a touch of finesse.
= Installing Arcanist SVN Hooks =
You can install Arcanist as an SVN pre-commit hook, to reject commits which
contain lint errors. The immediate value of this is that syntax errors won't
be committable, but you can block other kinds of badness with appropriate lint
engines.
To install Arcanist as a pre-commit hook, add this to your svn/hooks/pre-commit:
#!/bin/sh
set -e # Exit with an error code if this fails.
/usr/local/bin/php -f /path/to/arcanist/bin/arc svn-hook-pre-commit $@ 1>&2
Make sure you make this file executable, or you'll get an error for every commit
with an unhelpful error message. You also need to specify the full path to PHP
since SVN nukes ENV before executing scripts. Alternatively you can specify
PATH explicitly.
If your project is configured to run linters or lint engines which aren't part
of Arcanist, specify where to load them from with ##--load-phutil-library##:
--load-phutil-library=/path/to/library/root
Since SVN commit hooks run without access to a working copy, you'll need to keep
one checked out somewhere and reference it with ##--load-phutil-library## if you
build new linters or customize lint engines. For example, your hook might
look like this:
#!/bin/sh
set -e # Exit with an error code if this fails.
/usr/local/bin/php -f /path/to/arcanist/bin/arc svn-hook-pre-commit \
--load-phutil-library=/path/to/custom/lint/engine \
--load-phutil-library=/path/to/custom/unittest/engine \
$@ 1>&2