博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LINUX SVN 禁止删除操作和强制填写日志
阅读量:7040 次
发布时间:2019-06-28

本文共 2986 字,大约阅读时间需要 9 分钟。

hot3.png

!/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)
#
# 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.collab.net/repos/svn/trunk/tools/hook-scripts/ and
# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/

REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.

SVNLOOK=/usr/bin/svnlook
ACTION=`$SVNLOOK changed -t "$TXN" "$REPOS"|awk '{print $1}'`
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | \
  grep "[a-zA-Z0-9]" |wc -c` 
if [ "$LOGMSG" -lt 10 ]; then
   echo "hey ,my friend! Please Spare a bit time here to write log message! It do help later!" 1>&2
  exit 1
  else
    if [ $ACTION = D ]    ; then
           echo "Sorry,You can't DELETE any file or Directory!!!"1>&2
        exit 1
    fi
fi
exit 0

转载于:https://my.oschina.net/u/3457287/blog/993766

你可能感兴趣的文章
Android性能优化9-ANR完全解析
查看>>
C#是否简单?
查看>>
测试使用live writer
查看>>
js获取剪贴板内容
查看>>
开始学会记录
查看>>
一个技术人员35岁之前要做的10件事
查看>>
ajax提交form(文本数据以及文件上传)
查看>>
PHP7语法知识(二):流程控制语句、函数、字符串、数组
查看>>
bzoj2426
查看>>
hdu5803
查看>>
拉格朗日插值公式
查看>>
AGC006C Rabbit Exercise
查看>>
2019.1.7 Russia temperature control demo
查看>>
前端学HTTP之内容协商
查看>>
关于C#的数据绑定,存取数据库实例详解 (二)
查看>>
2017年计划
查看>>
一般对话框,单选复选对话框
查看>>
Java ExecutorService 的几种线程池比较
查看>>
个人最终总结
查看>>
关于vs2010开发的ASP项目部署到XPSP2系统上出现找不到Reportviewer.XX.文件的解决方案...
查看>>