[Centos7] svn hooks pre-commit 셋팅 제어

2016/07/07 - [Linux/Centos] - [Centos7] svn 설치

2016/08/02 - [Linux/Centos] - [Centos7] svn hooks post-commit 셋팅

svn 설치가 완료후


svn설치완료된 디렉토리로 이동


cd /usr/local/svn/hooks


해당경로에 가면 pre-commit.tmpl 이라는 파일이 있는데


파일명 변경 후 실행권한 설정

mv ./pre-commit.tmpl ./pre-commit

chmod 755 ./pre-commit 


이후

vi ./pre-commit


출처 :: https://www.lesstif.com/pages/viewpage.action?pageId=18220003

[기본적으로 출처에 내용이 상세히 있습니다]


-------------------------------------------------------

#!/usr/bin/php

<?php


# comment 가 6자 미만이면 커밋 거부

$minchars = 6;

$svnlook = 'svnlook';



#--------------------------------------------

$repos = $argv[1];

$txn = $argv[2];

$comment = `$svnlook log -t "$txn" "$repos"`;

$change = `$svnlook changed "$repos" -t "$txn"`;


$fileName = strrchr($change, "/");


fwrite(STDERR, "$change\n");

fwrite(STDERR, "$fileName\n");


$test = substr($fileName, 1,1);

fwrite(STDERR, "$test\n");


if(substr($fileName, 1, 1) == ".") {

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  fwrite(STDERR, "Your File or Directory [.] include do not commit File or Directory[.]\n");

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

}



$comment = chop($comment);


if ( strlen($comment) == 0 ) {

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  fwrite(STDERR, "plz write comment msg!!! length char > 6\n");

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  exit(1);

}

else if ( strlen($comment) < $minchars ) {

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  fwrite(STDERR, "Comment must be at least $minchars characters.\n");

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  exit(1);

}


## 커밋 메시지에 #123 처럼 redmine 이슈 번호가 들어 있는지 확인한다.

if (preg_match('/[^\d\n\r]#(?:[0-9]+)+.+/', $comment)) {

    # Successful match

} else {

  # Match attempt failed

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  fwrite(STDERR, "Comment must match REDMINE-ISSUE-NUMBER!!! \"$comment\"\n");

  fwrite(STDERR, "---------------------------------------------------------------------------\n");

  exit(1);

}

 

exit(0);

?>

-----------------------------------------------------------

커밋전에 주석체크 및 .으로시작하는 파일 커밋못하게 막고 레드마인 이슈

번호 #1 이있는지 파악해서 없으면 커밋못하게 막습니다 이걸 응용해서

사용하시면 됩니다.



'Operating System > Centos' 카테고리의 다른 글

[Centos7] apache2.4 보안권장 설정  (0) 2016.10.05
[Centos7] 프로세스 살리기  (0) 2016.08.02
[Centos7] svn hooks post-commit 셋팅  (0) 2016.08.02
[Centos7] svn 설치  (0) 2016.07.07
[Centos] 디렉토리 구조 및 용도  (0) 2016.07.07
블로그 이미지

pstree

pstree.. process...

,