atlassian_confluence_jira

jira svn pre commit 수정

Naan 2020. 7. 16. 20:52
반응형

#!/usr/bin/php

<?php

# comment 가 10자 미만이면 커밋 거부
$minchars = 10;
$svnlook = 'svnlook';


#--------------------------------------------
$repos = $argv[1];
$txn = $argv[2];
$comment = `$svnlook log -t "$txn" "$repos"`;

$comment = chop($comment);

if ( strlen($comment) == 0 ) {
  fwrite(STDERR, "---------------------------------------------------------------------------\n");
  fwrite(STDERR, "Your commit has been blocked because it didn't include a log message.!\n");
  fwrite(STDERR, "Do the commit again, this time with a log message that describes your changes.!\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);
}

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

} else {
  # Match attempt failed
  fwrite(STDERR, "---------------------------------------------------------------------------\n");
  fwrite(STDERR, "Comment must match JIRA-ISSUE-KEY!!! [KEY-NUMBER] \"$comment\"\n");
  fwrite(STDERR, "---------------------------------------------------------------------------\n");
  exit(1);
}

exit(0);
?>

반응형