Work essay -- pre-commit hook limit log length and file type submitted

Source: Internet
Author: User

Recently, I checked SVN and found that the size of the backed up files is extremely large. It takes more than 4 GB to back up data after two months. You can find many binary files automatically generated by IDE... My class. Well, if development is not conscious, it is only mandatory.

Google found this article: http://blog.csdn.net/clever101/article/details/8560833

Self-help clothes and food. The script is as follows:

#! /Bin/bashexport lang = "zh_CN.UTF-8" # Make sure that the Chinese log is displayed normally, easy to collect log repos = "$1" txn = "$2" # limit log length = 10 svnlook = "/usr/local/csvn/bin/svnlook" blacklist = "Target build classes bin/target. **. IML *. IPR *. iws *. class "function error_exit () {echo-e" 1.not allowed empty log "> & 2 echo-e" 2. logs must be greater than $ {length} characters or Chinese "> & 2 exit 1} function blacklist_exit () {if [! -Z "$ {inblacklist}"]; Then ECHO-e "some files in the blacklist, please cheack again! "> & 2 echo-e" blacklist: \ N $ {blacklist} "> & 2 exit 1 fi} # obtain the number of characters (including line breaks) temp_length = '$ {svnlook} log-T "$ {txn}" "$ {repos}" | SED's/\ s * $ // G' | SED's/ ^ \ s * // G' | WC -- chars' # statistical line break temp_line = '$ {svnlook} log-T "$ {txn}" "$ {repos}" | WC -- lines '# Number of real characters logmsg_length = 'expr $ {temp_length}-$ {temp_line}' # file blacklist filtering # filter folder inblacklist = "'$ {svnlook} changed-t" $ {txn} "" $ {repos} "| grep"/target/"'" # The folder must contain /, otherwise, blacklist_exitinblacklist = "'$ {svnlook} changed-T" $ {txn} "" $ {repos} "| grep"/build/"'" blacklist_exitinblacklist = "' $ {svnlook} changed-T "$ {txn}" "$ {repos}" | grep "/classes/" '"blacklist_exitinblacklist ="' $ {svnlook} changed-t" $ {txn} "" $ {repos} "| grep"/bin/target/"'" blacklist_exit # filter all files and folders starting with "dot". inblacklist = "' $ {svnlook} changed-T "$ {txn}" "$ {repos}" | grep "/\. "'" blacklist_exit # inblacklist = "' $ {svnlook} changed-T" $ {txn} "" $ {repos} "| grep "\. IML $ "'" blacklist_exitinblacklist = "' $ {svnlook} changed-T" $ {txn} "" $ {repos} "| grep "\. IPR $ "'" blacklist_exitinblacklist = "' $ {svnlook} changed-T" $ {txn} "" $ {repos} "| grep "\. iws $ "'" blacklist_exitinblacklist = "' $ {svnlook} changed-T" $ {txn} "" $ {repos} "| grep "\. class $ "'" blacklist_exit # determine whether the log length meets the requirements if ["$ {logmsg_length}"-lt $ {length}]; then error_exitfiexit 0

I don't know why. I cannot add Chinese characters to the returned logs. Otherwise, the turtle reported that the encoding could not be parsed. No one answered the question from the official website.

 

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.