Skip to content

Instantly share code, notes, and snippets.

@lesstif
Created September 28, 2014 14:43
Show Gist options
  • Save lesstif/52d12b2aad4959f1092b to your computer and use it in GitHub Desktop.
Save lesstif/52d12b2aad4959f1092b to your computer and use it in GitHub Desktop.
subversion pre-commit hook for redmine issue tracking system integration
#!/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);
}
## 커밋 메시지에 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);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment