/SIP Sorcery Dial Plans/hooks/pre-commit.tmpl

http://google-voice-sipsorcery-dialplans.googlecode.com/ · Shell · 81 lines · 7 code · 6 blank · 68 comment · 2 complexity · 289ff140d437c913b1a8b313f3df6fcc MD5 · raw file

  1. #!/bin/sh
  2. # PRE-COMMIT HOOK
  3. #
  4. # The pre-commit hook is invoked before a Subversion txn is
  5. # committed. Subversion runs this hook by invoking a program
  6. # (script, executable, binary, etc.) named 'pre-commit' (for which
  7. # this file is a template), with the following ordered arguments:
  8. #
  9. # [1] REPOS-PATH (the path to this repository)
  10. # [2] TXN-NAME (the name of the txn about to be committed)
  11. #
  12. # [STDIN] LOCK-TOKENS ** the lock tokens are passed via STDIN.
  13. #
  14. # If STDIN contains the line "LOCK-TOKENS:\n" (the "\n" denotes a
  15. # single newline), the lines following it are the lock tokens for
  16. # this commit. The end of the list is marked by a line containing
  17. # only a newline character.
  18. #
  19. # Each lock token line consists of a URI-escaped path, followed
  20. # by the separator character '|', followed by the lock token string,
  21. # followed by a newline.
  22. #
  23. # The default working directory for the invocation is undefined, so
  24. # the program should set one explicitly if it cares.
  25. #
  26. # If the hook program exits with success, the txn is committed; but
  27. # if it exits with failure (non-zero), the txn is aborted, no commit
  28. # takes place, and STDERR is returned to the client. The hook
  29. # program can use the 'svnlook' utility to help it examine the txn.
  30. #
  31. # On a Unix system, the normal procedure is to have 'pre-commit'
  32. # invoke other programs to do the real work, though it may do the
  33. # work itself too.
  34. #
  35. # *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***
  36. # *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***
  37. #
  38. # This is why we recommend using the read-only 'svnlook' utility.
  39. # In the future, Subversion may enforce the rule that pre-commit
  40. # hooks should not modify the versioned data in txns, or else come
  41. # up with a mechanism to make it safe to do so (by informing the
  42. # committing client of the changes). However, right now neither
  43. # mechanism is implemented, so hook writers just have to be careful.
  44. #
  45. # Note that 'pre-commit' must be executable by the user(s) who will
  46. # invoke it (typically the user httpd runs as), and that user must
  47. # have filesystem-level permission to access the repository.
  48. #
  49. # On a Windows system, you should name the hook program
  50. # 'pre-commit.bat' or 'pre-commit.exe',
  51. # but the basic idea is the same.
  52. #
  53. # The hook program typically does not inherit the environment of
  54. # its parent process. For example, a common problem is for the
  55. # PATH environment variable to not be set to its usual value, so
  56. # that subprograms fail to launch unless invoked via absolute path.
  57. # If you're having unexpected problems with a hook program, the
  58. # culprit may be unusual (or missing) environment variables.
  59. #
  60. # Here is an example hook script, for a Unix /bin/sh interpreter.
  61. # For more examples and pre-written hooks, see those in
  62. # the Subversion repository at
  63. # http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ and
  64. # http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/
  65. REPOS="$1"
  66. TXN="$2"
  67. # Make sure that the log message contains some text.
  68. SVNLOOK=/usr/local/bin/svnlook
  69. $SVNLOOK log -t "$TXN" "$REPOS" | \
  70. grep "[a-zA-Z0-9]" > /dev/null || exit 1
  71. # Check that the author of this commit has the rights to perform
  72. # the commit on the files and directories being modified.
  73. commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
  74. # All checks passed, so allow the commit.
  75. exit 0