微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Powershell SVN 挂钩将提交消息作为代码执行

如何解决Powershell SVN 挂钩将提交消息作为代码执行

我在 VisualSVN 中有一个预提交钩子来强制执行最小长度提交消息:

setlocal enabledelayedexpansion

set REPOS=$1
set TXN=%2

set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe"

set M=

REM Concatenate all the lines in the commit message
FOR /F "usebackq delims==" %%g IN (`%sVNLOOK% log -t %TXN% %rEPOS%`) DO SET M=!M!%%g

REM Make sure M is defined
SET M=0%M%

REM Here the 6 is the length we require
IF NOT "%M:~6,1%"=="" goto norMAL_EXIT

:ERROR_TOO_SHORT
echo "Commit note must be at least 6 letters" >&2
goto ERROR_EXIT

:ERROR_EXIT
exit /b 1

REM All checks passed,so allow the commit
:norMAL_EXIT
exit 0

它适用于大多数情况,但今天我尝试从另一个存储库复制 svn 日志并将其用作来自我的 linux 客户端的提交消息:

$ cat wc.log 
common-modules updated 13196 -> 13209
------------------------------------------------------------------------
r13209 | stew | 2021-02-26 09:14:34 +0100 (Fri,26 Feb 2021) | 1 line

No functional changes.  Removed warnings from a file in visual
------------------------------------------------------------------------
$ svn commit wc -F wc.log
Sending        wc
Committing transaction...
svn: E165001: Commit Failed (details follow):
svn: E165001: Commit blocked by pre-commit hook (exit code 255) with output:
'stew' is not recognized as an internal or external command,operable program or batch file.

我想阻止我的预提交钩子解析和运行提交消息。消息应仅被视为文本。我不知道 powershell(这是什么语言?),但我希望一些引号、方括号或转义字符可以避免这种情况。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。