start-commit.tmpl 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. # START-COMMIT HOOK
  3. #
  4. # The start-commit hook is invoked immediately after a Subversion txn is
  5. # created and populated with initial revprops in the process of doing a
  6. # commit. Subversion runs this hook by invoking a program (script,
  7. # executable, binary, etc.) named 'start-commit' (for which this file
  8. # is a template) with the following ordered arguments:
  9. #
  10. # [1] REPOS-PATH (the path to this repository)
  11. # [2] USER (the authenticated user attempting to commit)
  12. # [3] CAPABILITIES (a colon-separated list of capabilities reported
  13. # by the client; see note below)
  14. # [4] TXN-NAME (the name of the commit txn just created)
  15. #
  16. # Note: The CAPABILITIES parameter is new in Subversion 1.5, and 1.5
  17. # clients will typically report at least the "mergeinfo" capability.
  18. # If there are other capabilities, then the list is colon-separated,
  19. # e.g.: "mergeinfo:some-other-capability" (the order is undefined).
  20. #
  21. # Note: The TXN-NAME parameter is new in Subversion 1.8. Prior to version
  22. # 1.8, the start-commit hook was invoked before the commit txn was even
  23. # created, so the ability to inspect the commit txn and its metadata from
  24. # within the start-commit hook was not possible.
  25. #
  26. # The list is self-reported by the client. Therefore, you should not
  27. # make security assumptions based on the capabilities list, nor should
  28. # you assume that clients reliably report every capability they have.
  29. #
  30. # If the hook program exits with success, the commit continues; but
  31. # if it exits with failure (non-zero), the commit is stopped before
  32. # a Subversion txn is created, and STDERR is returned to the client.
  33. #
  34. # The default working directory for the invocation is undefined, so
  35. # the program should set one explicitly if it cares.
  36. #
  37. # On a Unix system, the normal procedure is to have 'start-commit'
  38. # invoke other programs to do the real work, though it may do the
  39. # work itself too.
  40. #
  41. # Note that 'start-commit' must be executable by the user(s) who will
  42. # invoke it (typically the user httpd runs as), and that user must
  43. # have filesystem-level permission to access the repository.
  44. #
  45. # On a Windows system, you should name the hook program
  46. # 'start-commit.bat' or 'start-commit.exe',
  47. # but the basic idea is the same.
  48. #
  49. # The hook program runs in an empty environment, unless the server is
  50. # explicitly configured otherwise. For example, a common problem is for
  51. # the PATH environment variable to not be set to its usual value, so
  52. # that subprograms fail to launch unless invoked via absolute path.
  53. # If you're having unexpected problems with a hook program, the
  54. # culprit may be unusual (or missing) environment variables.
  55. #
  56. # CAUTION:
  57. # For security reasons, you MUST always properly quote arguments when
  58. # you use them, as those arguments could contain whitespace or other
  59. # problematic characters. Additionally, you should delimit the list
  60. # of options with "--" before passing the arguments, so malicious
  61. # clients cannot bootleg unexpected options to the commands your
  62. # script aims to execute.
  63. # For similar reasons, you should also add a trailing @ to URLs which
  64. # are passed to SVN commands accepting URLs with peg revisions.
  65. #
  66. # Here is an example hook script, for a Unix /bin/sh interpreter.
  67. # For more examples and pre-written hooks, see those in
  68. # the Subversion repository at
  69. # http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ and
  70. # http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/
  71. REPOS="$1"
  72. USER="$2"
  73. commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1
  74. special-auth-check.py --user "$USER" --auth-level 3 || exit 1
  75. # All checks passed, so allow the commit.
  76. exit 0