summaryrefslogtreecommitdiff
path: root/app/Integration/GitlabWebhook.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-20 20:55:50 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-20 20:55:50 -0400
commit98fd34bfe340fae6d0fd3b7333b6f9a6647cbae2 (patch)
treed22b7bff634a05e73f89d423938776df43554f52 /app/Integration/GitlabWebhook.php
parent7b947ebdbd3b6bcd9de10ea4255bfa11fc88695c (diff)
Improve automatic action to create comments based on commit messages
Diffstat (limited to 'app/Integration/GitlabWebhook.php')
-rw-r--r--app/Integration/GitlabWebhook.php25
1 files changed, 14 insertions, 11 deletions
diff --git a/app/Integration/GitlabWebhook.php b/app/Integration/GitlabWebhook.php
index 8a11f5c6..dce7413a 100644
--- a/app/Integration/GitlabWebhook.php
+++ b/app/Integration/GitlabWebhook.php
@@ -3,7 +3,6 @@
namespace Integration;
use Event\GenericEvent;
-use Event\TaskEvent;
use Model\Task;
/**
@@ -116,7 +115,7 @@ class GitlabWebhook extends \Core\Base
{
$task_id = $this->task->getTaskIdFromText($commit['message']);
- if (! $task_id) {
+ if (empty($task_id)) {
return false;
}
@@ -126,17 +125,21 @@ class GitlabWebhook 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['url'],
+ 'commit_comment' => $commit['message']."\n\n[".t('Commit made by @%s on Gitlab', $commit['author']['name']).']('.$commit['url'].')'
+ ) + $task)
+ );
+
+ return true;
}
/**