适用于Windows的SVN挂钩

Gre*_*ean 35 svn repository svn-hooks

我做了一点谷歌搜索,发现没有真正的Windows资源SVN挂钩.所以我想我会在这里开始一个wiki来集中它.

如果您贡献,请务必注明:

  1. 钩子的名字
  2. 脚本的功能
  3. 实际的脚本

注意:我怀疑发布一个史诗脚本将没有用.

Gre*_*ean 11

使用空注释阻止提交

  1. 预提交
  2. 阻止空评论的提交

资源:

"c:\Program Files\Subversion\bin\svnlook.exe" log -t %2 %1 | FindStr [a-zA-Z0-9]
IF %ERRORLEVEL% EQU 0 GOTO OK
echo "Commit Comments are Required" >&2
exit 1
:OK
exit 0
Run Code Online (Sandbox Code Playgroud)


Gre*_*ean 8

防止编辑除svn :: log之外的修订道具

  1. 的pre-revprop-change.bat
  2. 防止编辑除svn :: log之外的修订版属性

@ECHO OFF
:: Set all parameters. Even though most are not used, in case you want to add
:: changes that allow, for example, editing of the author or addition of log messages.
set repository=%1
set revision=%2
set userName=%3
set propertyName=%4
set action=%5

:: Only allow the log message to be changed, but not author, etc.
if /I not "%propertyName%" == "svn:log" goto ERROR_PROPNAME

:: Only allow modification of a log message, not addition or deletion.
if /I not "%action%" == "M" goto ERROR_ACTION

:: Make sure that the new svn:log message is not empty.
set bIsEmpty=true
for /f "tokens=*" %%g in ('find /V ""') do (
set bIsEmpty=false
)
if "%bIsEmpty%" == "true" goto ERROR_EMPTY

goto :eof

:ERROR_EMPTY
echo Empty svn:log messages are not allowed. >&2
goto ERROR_EXIT

:ERROR_PROPNAME
echo Only changes to svn:log messages are allowed. >&2
goto ERROR_EXIT

:ERROR_ACTION
echo Only modifications to svn:log revision properties are allowed. >&2
goto ERROR_EXIT

:ERROR_EXIT
exit /b 1
Run Code Online (Sandbox Code Playgroud)


Por*_*man 6

*更新:这已不再适用,因为Twitter已弃用用户名/密码身份验证而支持OAuth.*

将提交信息发布到Twitter

  1. hook = post-commit的名称
  2. 脚本的作用=将修订,作者和提交消息发布到Twitter

使用说明:

  • twitterUsernametwitterPassword替换为您的实际Twitter
  • 这是针对VisualSVN进行测试的,我能让它工作的唯一方法是将所有内容转储到硬编码路径c:\ hook\post-commit中.您可以将其更改为VisualSVN具有读/写访问权限的任何路径.
  • 需要安装Wget.安装程序可以在这里下载
  • 欢迎评论和改进.这是我在Windows上的第一个SVN钩子,我的GAWD很痛苦.

实际的脚本

echo status= > c:\hook\post-commit\msg.txt
echo Rev#%2 by >> c:\hook\post-commit\msg.txt
"%VISUALSVN_SERVER%\bin\svnlook.exe" author -r %2 %1 >> c:\hook\post-commit\msg.txt
"%VISUALSVN_SERVER%\bin\svnlook.exe" log -r %2 %1 >> c:\hook\post-commit\msg.txt
"c:\Program Files (x86)\GnuWin32\bin\wget.exe" --user=twitterUsername --password=twitterPassword --post-file=c:\hook\post-commit\msg.txt --append-output=c:\hook\post-commit\log.txt --output-document=c:\hook\post-commit\download.txt --delete-after http://twitter.com/statuses/update.xml
Run Code Online (Sandbox Code Playgroud)