Settings that must be commented on when SVN commits on a Linux system

Source: Internet
Author: User
Tags stdin

How to install SVN under Linux system, here is not introduced, as for the want to see, please: Https://help.aliyun.com/document_detail/52864.html? Spm=5176.product25365.6.748.tdnkrc

In the SVN installation directory there is a hooks folder, modify the Pre-commit.tmpl file;

CP Pre-commit.tmpl Pre-commit

Modify the Pre-commit file

#!/bin/sh# pre-commit hook## the pre-commit hook is invoked before  a subversion txn is# committed.  subversion runs this hook  by invoking a program#  (script, executable, binary, etc.)  named  ' Pre-commit '   (for which# this file is a template),  with the following ordered arguments:##   [1] repos-path     (the path to this repository) #   [2] txn-name       (the name of the txn about to be committed) ##    [stdin] lock-tokens ** the lock tokens are passed via stdin .##   if stdin contains the line  "lock-tokens:\n"   (the  "\ n"  denotes a#  &Nbsp;single newline),  the lines following it are the lock tokens  for#   this commit.  The end of the list is  marked by a line containing#   only a newline character.##    each lock token line consists of a uri-escaped path,  followed#   by the separator character  ' | ',  followed by  the lock token string,#   followed by a newline.## the  default working directory for the invocation is undefined, so#  the program should set one explicitly if it cares.## if  the hook program exits with success, the txn is committed;  but# if it exits with failure  (Non-zero), the txn is aborted, no  commit# takes place, and stderr is returned to the client.    The hook# program can use the  ' Svnlook '  utility to  Help it examine the txn.## on a unix system, the normal  procedure is to have  ' Pre-commit ' # invoke other programs to  do the real work, though it may do the# work itself  too.##   ***  NOTE: THE HOOK PROGRAM MUST NOT  modify the txn, except  ***#   ***  for revision  properties  (like svn:log or svn:author).    ***##   this  is why we recommend using the read-only  ' Svnlook '  utility.#   in the future,  subversion may enforce the rule that pre-commit#   hooks  should not modify the versioned data in txns, or else  Come#   up with a mechanism to make it safe to do  so  (by informing the#   committing client of the  Changes) .  however, right now neither#   mechanism is  Implemented, so hook writers just have to be careful.## note  that  ' Pre-commit '  must be executable by the user (s)  who  will# invoke it  (Typically the user httpd runs as),  and that  user must# have filesystem-level permission to access the repository.## on a  windows system, you should name the hook program#  ' Pre-commit.bat '  or  ' Pre-commit.exe ', # but the basic idea is the same.## the  hook program typically does not inherit the environment of#  its parent process.  For example, a common problem is  For the# path environment variable to not be set to its  usual value, so# that subprograms fail to launch unless  Invoked via absolute path.# if you ' re having unexpected problems  with a hook program, the# culprit may be unusual  (or missing )  environment variables.## here is an example hook script, for a unix /bin/sh  interpreter.# for more examples and pre-written hooks, see those  in# the subversion repository at# http://svn.apache.org/repos/asf/subversion/trunk/ Tools/hook-scripts/ and# http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/repos = "$" txn= "$" # make sure that the log message contains some text. svnlook=/usr/bin/svnlook#  Add the following 5 lines of code logmsg= ' $SVNLOOK  log -t  $TXN   $REPOS  |  grep  "[a-za-z0-9]"  | wc -c ' if [  "$LOGMSG"  -lt 10 ];then     echo  "Submit failed:  comment cannot be less than 10 characters"  1>&2    exit  1fi#  all the following comments off #  $SVNLOOK  log -t  $TXN   $REPOS  | #    grep  "[a-za-z0-9]" &Nbsp;> /dev/null | |  exit 1# check that the author of this commit has the  rights to perform# the commit on the files and directories  being modified. #commit-access-control.pl  "$REPOS"   "$TXN"  commit-access-control.cfg  | |  exit 1# all checks passed, so allow the commit. #exit  0

In fact, the above to remove the comment section only a few lines of code:

#!/bin/shrepos= "$" txn= "$" Svnlook=/usr/bin/svnlook # svnlooklogmsg= ' $SVNLOOK log-t in Pre-commit.tmpl file "$TXN" "$ REPOS "| grep "[A-za-z0-9]" | Wc-c ' If ["$LOGMSG"-lt];then echo "Commit failed: Comment cannot be less than 10 characters" 1>&2 exit 1fi

Then add 755 permissions to the Pre-commit file:

chmod 755 pre-commit or chmod +x pre-commit

If no permission is added, it is reported:

Commit blocked by pre-commit hooks (exit code 255) with no output error, please note.


Also refer to: http://floscc.blog.51cto.com/1880249/533394

This article is from the "Yinbin" blog, make sure to keep this source http://yinbin99.blog.51cto.com/11392662/1982132

Settings that must be commented on when SVN commits on a Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.