Skip to content

Commit

Permalink
Check for tabs in a commit as well
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Mar 19, 2014
1 parent 91c1b9d commit 9d75cec
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions hooks/commits.php
Expand Up @@ -9,12 +9,18 @@

require_once('./lib/github.php');

$message = "This commit is missing Signed-Off-By line to indicate "
$message_sob = "This commit is missing Signed-Off-By line to indicate "
. "that you agree with phpMyAdmin Developer's Certificate of Origin. "
. "Please check [contributing documentation]("
. "https://github.com/phpmyadmin/phpmyadmin/blob/master/CONTRIBUTING.md"
. ") for more information.";

$message_tab = "This commit is using tab character for indentation instead "
. "of spaces, what is mandated by phpMyAdmin. Please check our "
. "[Developer guidelines]"
. "(http://wiki.phpmyadmin.net/pma/Developer_guidelines#Indentation)"
. " for more information.";

/* Parse JSON */
$data = json_decode($_POST['payload'], true);

Expand All @@ -34,12 +40,23 @@
/* List commits in the pull request */
$commits = github_pull_commits($data['pull_request']['number']);

/* Process commits in the pull request to find one missing SOB */
/* Process commits in the pull request */
foreach ($commits as $commit) {
/* Chek for missing SOB */
if ( ! preg_match("@\nSigned-off-by:@i", $commit['commit']['message'])) {
github_comment_commit($repo_name, $commit['sha'], $message);
echo 'Comment on ' . $commit['sha'] . ":\n";
github_comment_commit($repo_name, $commit['sha'], $message_sob);
echo 'Comment (SOB) on ' . $commit['sha'] . ":\n";
echo $commit['commit']['message'];
echo "\n";
}
/* Check for tab in diff */
foreach ($commit['files'] as $file) {
if (strpos($file['patch'], "\t") !== false) {
github_comment_commit($repo_name, $commit['sha'], $message_tab);
echo 'Comment (TAB) on ' . $commit['sha'] . ":\n";
echo $commit['commit']['message'];
echo "\n";
break;
}
}
}

0 comments on commit 9d75cec

Please sign in to comment.