Programing

댓글없이 Subversion 커밋을 방지하려면 어떻게해야합니까?

lottogame 2020. 11. 18. 08:21
반응형

댓글없이 Subversion 커밋을 방지하려면 어떻게해야합니까?


입력 된 커밋 주석이 없을 때 Subversion 코드 저장소에 대한 커밋을 방지하는 방법을 아는 사람이 있습니까?


후크를 사용할 수 있습니다 (입력 <repository>/hooks하고 이름 지정 pre-commit.bat(Windows)) :

@echo off
::
:: Stops commits that have empty log messages.
::

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an empty log message
svnlook log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else exit 0

:err
echo. 1>&2
echo Your commit has been blocked because you didn't give any log message 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1

소스 : http://www.anujgakhar.com/2008/02/14/how-to-force-comments-on-svn-commit/


다음은 Linux 용 @miku의 자세한 오류 메시지가있는 사전 커밋 후크입니다.

#!/bin/sh

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

SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
   grep "[a-zA-Z0-9]" > /dev/null

GREP_STATUS=$?
if [ $GREP_STATUS -ne 0 ]
then
    echo "Your commit has been blocked because you didn't give any log message" 1>&2
    echo "Please write a log message describing the purpose of your changes and" 1>&2
    echo "then try committing again. -- Thank you" 1>&2
    exit 1
fi
exit 0

실제로 Subversion 저장소를 만들 때 해당 hooks하위 디렉토리에는 이미 후크 샘플이 포함되어 있습니다. pre-commit.tmpl후크의 매개 변수에 대한 세부 사항을 위해 호출 된 것을 확인하십시오 . 또한 찾고있는 후크에 대한 예제도 포함되어 있습니다.

#!/bin/sh
REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.
SVNLOOK=/usr/local/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
   grep "[a-zA-Z0-9]" > /dev/null || exit 1

Subversion 컴퓨터에서 실행 가능한 한 모든 스크립트 또는 언어로 후크를 작성할 수 있습니다.


Create a pre-commit hook. Here's some instructions on how to do so yourself, or here is an example hook script that will reject anything with a commit message shorter than 10 characters.


Linux script for more than 15 characters--

#!/bin/bash
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
# Comments should have more than 5 characters
LOGMSG=$($SVNLOOK log -t "$TXN" "$REPOS" | grep [a-zA-Z0-9] | wc -c)
if [ "$LOGMSG" -lt 15 ];
then
echo -e "Please provide a meaningful comment when committing changes." 1>&2
exit 1
fi

Source-http://java.dzone.com/articles/useful-subversion-pre-commit


If you are using TortoiseSVN only then you can add TortoiseSVN's property to the root directory: property name: tsvn:logminsize value: 1 This will disable OK button in TortoiseSVN commit window then Message is empty. Please be aware that this property is TortoiseSVN specific it might not work with other SVN client.

참고URL : https://stackoverflow.com/questions/1928023/how-can-i-prevent-subversion-commits-without-comments

반응형