+ mr->notFound;?> + + createLink('mr', 'create'), " " . $lang->mr->create, '', "class='btn btn-info'");?> + +
+diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 0320cd7472..087fadabc5 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -470,6 +470,21 @@ class gitlabModel extends model return json_decode(commonModel::http($url)); } + /** + * Get single branch by API. + * + * @param int $gitlabID + * @param int $projectID + * @param string $branch + * @access public + * @return object + */ + public function apiGetSingleBranch($gitlabID, $projectID, $branch) + { + $url = sprintf($this->getApiRoot($gitlabID), "/projects/$projectID/repository/branches/$branch"); + return json_decode(commonModel::http($url)); + } + /** * Get Forks of a project by API. * diff --git a/module/mr/control.php b/module/mr/control.php index 12038bc8f4..495b6d8b1a 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -110,6 +110,22 @@ class mr extends control $this->view->MR = $MR; $this->view->rawMR = isset($rawMR) ? $rawMR : false; + $this->loadModel('gitlab'); + $sourceProject = $this->gitlab->apiGetSingleProject($MR->gitlabID, $MR->sourceProject); + $targetProject = $this->gitlab->apiGetSingleProject($MR->gitlabID, $MR->targetProject); + $sourceBranch = $this->gitlab->apiGetSingleBranch($MR->gitlabID, $MR->sourceProject, $MR->sourceBranch); + $targetBranch = $this->gitlab->apiGetSingleBranch($MR->gitlabID, $MR->targetProject, $MR->targetBranch); + + $this->view->sourceProjectName = $sourceProject->name_with_namespace; + $this->view->targetProjectName = $targetProject->name_with_namespace; + $this->view->sourceProjectURL = $sourceBranch ->web_url; + $this->view->targetProjectURL = $targetBranch ->web_url; + + + /* Those variables are used to render $lang->mr->commandDocument. */ + $this->view->httpRepoURL = $sourceProject->http_url_to_repo; + $this->view->branchPath = $sourceProject->path_with_namespace . '-' . $rawMR->source_branch; + $this->display(); } diff --git a/module/mr/lang/zh-cn.php b/module/mr/lang/zh-cn.php index 229fd39fa4..5ae6e62d8a 100644 --- a/module/mr/lang/zh-cn.php +++ b/module/mr/lang/zh-cn.php @@ -18,6 +18,8 @@ $lang->mr->assignee = '指派给'; $lang->mr->reviewer = '评审人'; $lang->mr->link = 'GitLab链接'; $lang->mr->mergeStatus = '是否可合并'; +$lang->mr->commits = '提交数'; +$lang->mr->changes = '更改数'; $lang->mr->statusList = array(); $lang->mr->statusList['opened'] = '开放中'; @@ -44,3 +46,54 @@ $lang->mr->accessGitlabFailed = "当前无法连接到GitLab服务器。"; $lang->mr->description = "描述"; +$lang->mr->from = "请求合并"; +$lang->mr->to = "入"; +$lang->mr->at = "于"; +$lang->mr->pipeline = "流水线"; +$lang->mr->pipelineSuccess = "已通过"; +$lang->mr->pipelineFailed = "未通过"; +$lang->mr->pipelineCancled = "已取消"; +$lang->mr->pipelineUnknown = "未知"; + +$lang->mr->pipelineStatus = array(); +$lang->mr->pipelineStatus['success'] = "已通过"; +$lang->mr->pipelineStatus['failed'] = "未通过"; +$lang->mr->pipelineStatus['canceled'] = "已取消"; + +$lang->mr->MRHasConflicts = "是否存在合并冲突"; +$lang->mr->hasConflicts = "存在合并冲突"; +$lang->mr->hasNoConflict = "可以合并请求"; +$lang->mr->mergeByManual = "此合并请求可以手动合并,请使用以下"; +$lang->mr->commandLine = "命令行"; + +/** + * Merge Command Document. + * + * %s source_roject::http_url_to_repo + * %s mr::source_branch + * %s source_project::path_with_namespace . '-' . mr::source_branch + * %s mr::target_branch + * %s source_project::path_with_namespace . '-' . mr::source_branch + * %s mr::target_branch + */ +$lang->mr->commandDocument = <<< EOD +
+ git fetch "%s" %s + git checkout -b "%s" FETCH_HEAD ++ 第 2 步. 在本地查看更改 +
+ git fetch origin + git checkout "%s" + git merge --no-ff "%s" ++ 第 4 步. 将合并结果推送到GitLab +
+ git push origin "%s" ++EOD; + diff --git a/module/mr/view/view.html.php b/module/mr/view/view.html.php new file mode 100644 index 0000000000..bd7af3990c --- /dev/null +++ b/module/mr/view/view.html.php @@ -0,0 +1,46 @@ + +id)):?> +
+ mr->notFound;?> + + createLink('mr', 'create'), " " . $lang->mr->create, '', "class='btn btn-info'");?> + +
+