diff --git a/module/git/model.php b/module/git/model.php index 628409b82a..16461929c9 100644 --- a/module/git/model.php +++ b/module/git/model.php @@ -166,7 +166,31 @@ class gitModel extends model ' task:' . join(' ', $objects['tasks']) . ' bug:' . join(',', $objects['bugs'])); - $this->repo->saveAction2PMS($objects, $log, $this->repoRoot, $repo->encoding, 'git'); + if($repo->SCM == 'Gitlab') + { + if(!isset($gitlabAccountPairs)) + { + $gitlabAccountPairs = array(); + $gitlabUserList = $this->loadModel('gitlab')->apiGetUsers($repo->gitlab); + $acountIDPairs = $this->gitlab->getUserIdAccountPairs($repo->gitlab); + foreach($acountIDPairs as $openID => $account) + { + foreach($gitlabUserList as $gitlabUser) + { + if($gitlabUser->id == $openID) + { + $gitlabAccountPairs[$gitlabUser->realname] = $account; + break; + } + } + } + } + $this->repo->saveAction2PMS($objects, $log, $this->repoRoot, $repo->encoding, 'git', $gitlabAccountPairs); + } + else + { + $this->repo->saveAction2PMS($objects, $log, $this->repoRoot, $repo->encoding, 'git'); + } } else { diff --git a/module/mr/model.php b/module/mr/model.php index 415f3501da..7851aa6ce8 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -555,6 +555,9 @@ class mrModel extends model ->fetch(); if(empty($todoDesc)) { + $acountPairs = $this->gitlab->getUserIdRealnamePairs($gitlabID); + $author = isset($acountPairs[$rawTodo->author->id]) ? $acountPairs[$rawTodo->author->id] : $rawTodo->author->name; + $todo = new stdClass; $todo->account = $this->app->user->account; $todo->assignedTo = $account; @@ -567,7 +570,7 @@ class mrModel extends model $todo->idvalue = $rawTodo->id; $todo->pri = 3; $todo->name = $this->lang->mr->common . ": " . $rawTodo->target->title; - $todo->desc = $rawTodo->target->assignee->name . ' ' . $this->lang->mr->at . ' ' . '' . $rawTodo->project->path .'' . ' ' . $this->lang->mr->todomessage . '' . ' ' . $this->lang->mr->common .'' . '。'; + $todo->desc = $author . ' ' . $this->lang->mr->at . ' ' . '' . $rawTodo->project->path .'' . ' ' . $this->lang->mr->todomessage . '' . ' ' . $this->lang->mr->common .'' . '。'; $todo->status = 'wait'; $todo->finishedBy = ''; diff --git a/module/repo/model.php b/module/repo/model.php index ab12ca3c29..4913c28557 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -1533,11 +1533,16 @@ class repoModel extends model * @param array $objects * @param object $log * @param string $repoRoot + * @param string $encodings + * @param string $scm + * @param array $gitlabAccountPairs * @access public * @return void */ - public function saveAction2PMS($objects, $log, $repoRoot = '', $encodings = 'utf-8', $scm = 'svn') + public function saveAction2PMS($objects, $log, $repoRoot = '', $encodings = 'utf-8', $scm = 'svn', $gitlabAccountPairs = array()) { + $log->author = isset($gitlabAccountPairs[$log->author]) ? $gitlabAccountPairs[$log->author] : $log->author; + if(isset($this->app->user)) { $account = $this->app->user->account;