From 98fd34bfe340fae6d0fd3b7333b6f9a6647cbae2 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 20 Jun 2015 20:55:50 -0400 Subject: Improve automatic action to create comments based on commit messages --- app/Integration/BitbucketWebhook.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'app/Integration/BitbucketWebhook.php') diff --git a/app/Integration/BitbucketWebhook.php b/app/Integration/BitbucketWebhook.php index 75fc1c81..eced5596 100644 --- a/app/Integration/BitbucketWebhook.php +++ b/app/Integration/BitbucketWebhook.php @@ -2,7 +2,7 @@ namespace Integration; -use Event\TaskEvent; +use Event\GenericEvent; use Model\Task; /** @@ -72,7 +72,7 @@ class BitbucketWebhook extends \Core\Base { $task_id = $this->task->getTaskIdFromText($commit['message']); - if (! $task_id) { + if (empty($task_id)) { return false; } @@ -82,16 +82,20 @@ class BitbucketWebhook extends \Core\Base return false; } - if ($task['is_active'] == Task::STATUS_OPEN && $task['project_id'] == $this->project_id) { - - $this->container['dispatcher']->dispatch( - self::EVENT_COMMIT, - new TaskEvent(array('task_id' => $task_id) + $task) - ); - - return true; + if ($task['project_id'] != $this->project_id) { + return false; } - return false; + $this->container['dispatcher']->dispatch( + self::EVENT_COMMIT, + new GenericEvent(array( + 'task_id' => $task_id, + 'commit_message' => $commit['message'], + 'commit_url' => '', + 'commit_comment' => $commit['message']."\n\n".t('Commit made by @%s on Bitbucket', $commit['author']) + ) + $task) + ); + + return true; } } -- cgit v1.2.3