Improve automatic action to create comments based on commit messages

This commit is contained in:
Frederic Guillot
2015-06-20 20:55:50 -04:00
parent 7b947ebdbd
commit 98fd34bfe3
9 changed files with 139 additions and 41 deletions

View File

@@ -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;
}
}

View File

@@ -90,12 +90,19 @@ class GithubWebhook extends \Core\Base
continue;
}
if ($task['project_id'] == $this->project_id) {
$this->container['dispatcher']->dispatch(
self::EVENT_COMMIT,
new GenericEvent(array('task_id' => $task_id) + $task)
);
if ($task['project_id'] != $this->project_id) {
continue;
}
$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 Github', $commit['author']['username']).']('.$commit['url'].')'
) + $task)
);
}
return true;

View File

@@ -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;
}
/**