📄 repos.c
字号:
APR_EOL_STR "# The pre-commit hook is invoked before a Subversion txn is" APR_EOL_STR "# committed. Subversion runs this hook by invoking a program" APR_EOL_STR "# (script, executable, binary, etc.) named " "'" SVN_REPOS__HOOK_PRE_COMMIT "' (for which" APR_EOL_STR "# this file is a template), with the following ordered arguments:" APR_EOL_STR "#" APR_EOL_STR "# [1] REPOS-PATH (the path to this repository)" APR_EOL_STR "# [2] TXN-NAME (the name of the txn about to be committed)" APR_EOL_STR "#" APR_EOL_STR "# The default working directory for the invocation is undefined, so" APR_EOL_STR "# the program should set one explicitly if it cares." APR_EOL_STR "#" APR_EOL_STR "# If the hook program exits with success, the txn is committed; but" APR_EOL_STR "# if it exits with failure (non-zero), the txn is aborted, no commit" APR_EOL_STR "# takes place, and STDERR is returned to the client. The hook" APR_EOL_STR "# program can use the 'svnlook' utility to help it examine the txn." APR_EOL_STR "#" APR_EOL_STR "# On a Unix system, the normal procedure is to have " "'" SVN_REPOS__HOOK_PRE_COMMIT "'" APR_EOL_STR "# invoke other programs to do the real work, though it may do the" APR_EOL_STR "# work itself too." APR_EOL_STR "#" APR_EOL_STR "# *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***" APR_EOL_STR "# *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***" APR_EOL_STR "#" APR_EOL_STR "# This is why we recommend using the read-only 'svnlook' utility." APR_EOL_STR "# In the future, Subversion may enforce the rule that pre-commit" APR_EOL_STR "# hooks should not modify the versioned data in txns, or else come" APR_EOL_STR "# up with a mechanism to make it safe to do so (by informing the" APR_EOL_STR "# committing client of the changes). However, right now neither" APR_EOL_STR "# mechanism is implemented, so hook writers just have to be careful." APR_EOL_STR "#" APR_EOL_STR "# Note that" " '" SVN_REPOS__HOOK_PRE_COMMIT "' " "must be executable by the user(s) who will" APR_EOL_STR "# invoke it (typically the user httpd runs as), and that user must" APR_EOL_STR "# have filesystem-level permission to access the repository." APR_EOL_STR "#" APR_EOL_STR "# On a Windows system, you should name the hook program" APR_EOL_STR "# '" SVN_REPOS__HOOK_PRE_COMMIT ".bat' or " "'" SVN_REPOS__HOOK_PRE_COMMIT ".exe'," APR_EOL_STR "# but the basic idea is the same." APR_EOL_STR "#" APR_EOL_STR HOOKS_ENVIRONMENT_TEXT "# " APR_EOL_STR "# Here is an example hook script, for a Unix /bin/sh interpreter." APR_EOL_STR PREWRITTEN_HOOKS_TEXT APR_EOL_STR APR_EOL_STR "REPOS=\"$1\"" APR_EOL_STR "TXN=\"$2\"" APR_EOL_STR APR_EOL_STR "# Make sure that the log message contains some text." APR_EOL_STR "SVNLOOK=" SVN_BINDIR "/svnlook" APR_EOL_STR "$SVNLOOK log -t \"$TXN\" \"$REPOS\" | \\" APR_EOL_STR " grep \"[a-zA-Z0-9]\" > /dev/null || exit 1" APR_EOL_STR APR_EOL_STR "# Check that the author of this commit has the rights to perform" APR_EOL_STR "# the commit on the files and directories being modified." APR_EOL_STR "commit-access-control.pl \"$REPOS\" \"$TXN\" commit-access-control.cfg " "|| exit 1" APR_EOL_STR APR_EOL_STR "# All checks passed, so allow the commit." APR_EOL_STR "exit 0" APR_EOL_STR; SVN_ERR_W(svn_io_file_create(this_path, contents, pool), _("Creating pre-commit hook")); } /* end pre-commit hook */ /* Pre-revprop-change hook. */ { this_path = apr_psprintf(pool, "%s%s", svn_repos_pre_revprop_change_hook(repos, pool), SVN_REPOS__HOOK_DESC_EXT); contents = "#!/bin/sh" APR_EOL_STR APR_EOL_STR "# PRE-REVPROP-CHANGE HOOK" APR_EOL_STR "#" APR_EOL_STR "# The pre-revprop-change hook is invoked before a revision property" APR_EOL_STR "# is added, modified or deleted. Subversion runs this hook by invoking" APR_EOL_STR "# a program (script, executable, binary, etc.) named '" SVN_REPOS__HOOK_PRE_REVPROP_CHANGE "'" APR_EOL_STR "# (for which this file is a template), with the following ordered" APR_EOL_STR "# arguments:" APR_EOL_STR "#" APR_EOL_STR "# [1] REPOS-PATH (the path to this repository)" APR_EOL_STR "# [2] REVISION (the revision being tweaked)" APR_EOL_STR "# [3] USER (the username of the person tweaking the property)" APR_EOL_STR "# [4] PROPNAME (the property being set on the revision)" APR_EOL_STR "# [5] ACTION (the property is being 'A'dded, 'M'odified, or " "'D'eleted)" APR_EOL_STR "#" APR_EOL_STR "# [STDIN] PROPVAL ** the new property value is passed via STDIN." APR_EOL_STR "#" APR_EOL_STR "# If the hook program exits with success, the propchange happens; but" APR_EOL_STR "# if it exits with failure (non-zero), the propchange doesn't happen." APR_EOL_STR "# The hook program can use the 'svnlook' utility to examine the " APR_EOL_STR "# existing value of the revision property." APR_EOL_STR "#" APR_EOL_STR "# WARNING: unlike other hooks, this hook MUST exist for revision" APR_EOL_STR "# properties to be changed. If the hook does not exist, Subversion " APR_EOL_STR "# will behave as if the hook were present, but failed. The reason" APR_EOL_STR "# for this is that revision properties are UNVERSIONED, meaning that" APR_EOL_STR "# a successful propchange is destructive; the old value is gone" APR_EOL_STR "# forever. We recommend the hook back up the old value somewhere." APR_EOL_STR "#" APR_EOL_STR "# On a Unix system, the normal procedure is to have " "'" SVN_REPOS__HOOK_PRE_REVPROP_CHANGE "'" APR_EOL_STR "# invoke other programs to do the real work, though it may do the" APR_EOL_STR "# work itself too." APR_EOL_STR "#" APR_EOL_STR "# Note that" " '" SVN_REPOS__HOOK_PRE_REVPROP_CHANGE "' " "must be executable by the user(s) who will" APR_EOL_STR "# invoke it (typically the user httpd runs as), and that user must" APR_EOL_STR "# have filesystem-level permission to access the repository." APR_EOL_STR "#" APR_EOL_STR "# On a Windows system, you should name the hook program" APR_EOL_STR "# '" SVN_REPOS__HOOK_PRE_REVPROP_CHANGE ".bat' or " "'" SVN_REPOS__HOOK_PRE_REVPROP_CHANGE ".exe'," APR_EOL_STR "# but the basic idea is the same." APR_EOL_STR "#" APR_EOL_STR HOOKS_ENVIRONMENT_TEXT "# " APR_EOL_STR "# Here is an example hook script, for a Unix /bin/sh interpreter." APR_EOL_STR PREWRITTEN_HOOKS_TEXT APR_EOL_STR APR_EOL_STR "REPOS=\"$1\"" APR_EOL_STR "REV=\"$2\"" APR_EOL_STR "USER=\"$3\"" APR_EOL_STR "PROPNAME=\"$4\"" APR_EOL_STR "ACTION=\"$5\"" APR_EOL_STR APR_EOL_STR "if [ \"$ACTION\" = \"M\" -a \"$PROPNAME\" = \"svn:log\" ]; " "then exit 0; fi" APR_EOL_STR APR_EOL_STR "echo \"Changing revision properties other than svn:log is " "prohibited\" >&2" APR_EOL_STR "exit 1" APR_EOL_STR; SVN_ERR_W(svn_io_file_create(this_path, contents, pool), _("Creating pre-revprop-change hook")); } /* end pre-revprop-change hook */ /* Pre-lock hook. */ { this_path = apr_psprintf(pool, "%s%s", svn_repos_pre_lock_hook(repos, pool), SVN_REPOS__HOOK_DESC_EXT); contents = "#!/bin/sh" APR_EOL_STR APR_EOL_STR "# PRE-LOCK HOOK" APR_EOL_STR "#" APR_EOL_STR "# The pre-lock hook is invoked before an exclusive lock is" APR_EOL_STR "# created. Subversion runs this hook by invoking a program " APR_EOL_STR "# (script, executable, binary, etc.) named " "'" SVN_REPOS__HOOK_PRE_LOCK "' (for which" APR_EOL_STR "# this file is a template), with the following ordered arguments:" APR_EOL_STR "#" APR_EOL_STR "# [1] REPOS-PATH (the path to this repository)" APR_EOL_STR "# [2] PATH (the path in the repository about to be locked)" APR_EOL_STR "# [3] USER (the user creating the lock)" APR_EOL_STR "#" APR_EOL_STR "# The default working directory for the invocation is undefined, so" APR_EOL_STR "# the program should set one explicitly if it cares." APR_EOL_STR "#" APR_EOL_STR "# If the hook program exits with success, the lock is created; but" APR_EOL_STR "# if it exits with failure (non-zero), the lock action is aborted" APR_EOL_STR "# and STDERR is returned to the client." APR_EOL_STR APR_EOL_STR "# On a Unix system, the normal procedure is to have " "'" SVN_REPOS__HOOK_PRE_LOCK "'" APR_EOL_STR "# invoke other programs to do the real work, though it may do the" APR_EOL_STR "# work itself too." APR_EOL_STR "#" APR_EOL_STR "# Note that" " '" SVN_REPOS__HOOK_PRE_LOCK "' " "must be executable by the user(s) who will" APR_EOL_STR "# invoke it (typically the user httpd runs as), and that user must" APR_EOL_STR "# have filesystem-level permission to access the repository." APR_EOL_STR "#" APR_EOL_STR "# On a Windows system, you should name the hook program" APR_EOL_STR "# '" SVN_REPOS__HOOK_PRE_LOCK ".bat' or " "'" SVN_REPOS__HOOK_PRE_LOCK ".exe'," APR_EOL_STR "# but the basic idea is the same." APR_EOL_STR "#" APR_EOL_STR "# Here is an example hook script, for a Unix /bin/sh interpreter:" APR_EOL_STR APR_EOL_STR "REPOS=\"$1\"" APR_EOL_STR "PATH=\"$2\"" APR_EOL_STR "USER=\"$3\"" APR_EOL_STR APR_EOL_STR "# If a lock exists and is owned by a different person, don't allow it" APR_EOL_STR "# to be stolen (e.g., with 'svn lock --force ...')." APR_EOL_STR APR_EOL_STR "# (Maybe this script could send email to the lock owner?)" APR_EOL_STR "SVNLOOK=" SVN_BINDIR "/svnlook" APR_EOL_STR "GREP=/bin/grep" APR_EOL_STR "SED=/bin/sed" APR_EOL_STR APR_EOL_STR "LOCK_OWNER=`$SVNLOOK lock \"$REPOS\" \"$PATH\" | \\" APR_EOL_STR " $GREP '^Owner: ' | $SED 's/Owner: //'`" APR_EOL_STR APR_EOL_STR "# If we get no result from svnlook, there's no lock, allow the lock to" APR_EOL_STR "# happen:" APR_EOL_STR "if [ \"$LOCK_OWNER\" = \"\" ]; then" APR_EOL_STR " exit 0" APR_EOL_STR "fi" APR_EOL_STR APR_EOL_STR "# If the person locking matches the lock's owner, allow the lock to" APR_EOL_STR "# happen:" APR_EOL_STR "if [ \"$LOCK_OWNER\" = \"$USER\" ]; then" APR_EOL_STR " exit 0" APR_EOL_STR "fi" APR_EOL_STR APR_EOL_STR "# Otherwise, we've got an owner mismatch, so return failure:" APR_EOL_STR "echo \"Error: $PATH already locked by ${LOCK_OWNER}.\" 1>&2" APR_EOL_STR "exit 1" APR_EOL_STR; SVN_ERR_W(svn_io_file_create(this_path, contents, pool), "Creating pre-lock hook"); } /* end pre-lock hook */ /* Pre-unlock hook. */ { this_path = apr_psprintf(pool, "%s%s", svn_repos_pre_unlock_hook(repos, pool), SVN_REPOS__HOOK_DESC_EXT); contents = "#!/bin/sh" APR_EOL_STR APR_EOL_STR "# PRE-UNLOCK HOOK" APR_EOL_STR "#" APR_EOL_STR "# The pre-unlock hook is invoked before an exclusive lock is" APR_EOL_STR "# destroyed. Subversion runs this hook by invoking a program " APR_EOL_STR "# (script, executable, binary, etc.) named " "'" SVN_REPOS__HOOK_PRE_UNLOCK "' (for which" APR_EOL_STR "# this file is a template), with the following ordered arguments:" APR_EOL_STR "#" APR_EOL_STR "# [1] REPOS-PATH (the path to this repository)" APR_EOL_STR "# [2] PATH (the path in the repository about to be unlocked)" APR_EOL_STR "# [3] USER (the user destroying the lock)"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -