diff --git a/module/ci/config.php b/module/ci/config.php index 2717c30d7f..e85ee96adf 100644 --- a/module/ci/config.php +++ b/module/ci/config.php @@ -15,4 +15,4 @@ $config->repo->binary = '|pdf|'; $config->repo->requiredFields = 'name,repo,buildType,jenkins,jenkinsTask,triggerType'; -$config->repo->commitCommands = array( entity => '/\s*([a-z]+)\s+((?:build)|(?:story)|(?:task)|(?:bug))\s+#((\d|,)+)\s*/i' ); \ No newline at end of file +$config->repo->commitCommands = array( entity => '/\s*([a-z]+)\s+((?:build)|(?:story)|(?:task)|(?:bug))\s+#((?:\d|,)+)\s*/i' ); \ No newline at end of file diff --git a/module/cron/control.php b/module/cron/control.php index 5b5faef8c2..f85d50fcf1 100644 --- a/module/cron/control.php +++ b/module/cron/control.php @@ -222,9 +222,9 @@ class cron extends control $log = ''; $time = $now->format('G:i:s'); if (empty($output)) { - $output = '\n'; + $output = "\n"; } - if (count($output) > 100) { // return if output a lot of info + if (strlen($output) > 100) { // return if output a lot of info $output = "\n" . $output; } $log = "$time task " . $id . " executed,\ncommand: $cron[command].\nreturn : $return.\noutput : $output\n"; diff --git a/module/git/model.php b/module/git/model.php index d870a8b32f..2adb29f9fb 100644 --- a/module/git/model.php +++ b/module/git/model.php @@ -102,6 +102,8 @@ class gitModel extends model $this->printLog("get " . count($logs) . " logs"); $this->printLog('begin parsing logs'); $latestRevision = $logs[0]->revision; + + $allCommands = new stdClass(); foreach($logs as $log) { $this->printLog("parsing log {$log->revision}"); @@ -112,10 +114,7 @@ class gitModel extends model } $this->printLog("comment is\n----------\n" . trim($log->msg) . "\n----------"); - $objects = $this->parseComment($log->msg); - if($objects) { - $this->printLog('extract ' . json_encode($objects)); - } + $this->parseComment($log->msg, $allCommands); } $this->saveLastRevision($latestRevision); @@ -123,11 +122,7 @@ class gitModel extends model $this->deleteRestartFile(); $this->printLog("\n\nrepo ' . $repo->id . ': ' . $repo->path . ' finished"); - // check ci commands in logs - $pattern = $this->config->repo->commitCommands['entity']; - $matches = array(); - preg_match($pattern, 'fix bug #123',$matches); - + $this->printLog('extract ' . json_encode($allCommands)); } } @@ -388,14 +383,13 @@ class gitModel extends model /** * Parse the comment of git, extract object id list from it. * - * @param string $comment + * @param string $comment + * @param array $allCommands * @access public * @return array */ - public function parseComment($comment) + public function parseComment($comment, &$allCommands) { - $ret = array(); - $pattern = $this->config->repo->commitCommands['entity']; $matches = array(); preg_match($pattern, $comment,$matches); @@ -405,10 +399,11 @@ class gitModel extends model $entityType = $matches[2]; $entityIds = $matches[3]; - $ret[$entityType] = array('action'=>$action, 'entities'=> explode(",", $entityIds)); - } + $currArr = $allCommands[$entityType][$action]; + $newArr = explode(",", $entityIds); - return $ret; + $allCommands[$entityType][$action] = array_keys(array_flip($currArr) + array_flip($newArr)); + } } /**