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 (将#修改为@)