Merge branch 'jihuMR' of https://gitlab.zcorp.cc/easycorp/zentaopms into jihuMR

This commit is contained in:
Guan Xiying
2021-08-25 10:33:09 +08:00
4 changed files with 130 additions and 0 deletions
+15
View File
@@ -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.
*
+16
View File
@@ -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();
}
+53
View File
@@ -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
<h4>在本地检出、审核和合并</h4>
<strong>第 1 步</strong>. 获取并查看此合并请求的分支
<pre>
git fetch "%s" %s
git checkout -b "%s" FETCH_HEAD
</pre>
<strong>第 2 步</strong>. 在本地查看更改
<br>
<strong>第 3 步</strong>. 合并分支并解决出现的任何冲突
<pre>
git fetch origin
git checkout "%s"
git merge --no-ff "%s"
</pre>
<strong>第 4 步</strong>. 将合并结果推送到GitLab
<pre>
git push origin "%s"
</pre>
EOD;
+46
View File
@@ -0,0 +1,46 @@
<?php include '../../common/view/header.html.php';?>
<?php if(!isset($MR->id)):?>
<div id='mainContent'>
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $lang->mr->notFound;?></span>
<?php if(common::hasPriv('mr', 'create')):?>
<?php echo html::a($this->createLink('mr', 'create'), "<i class='icon icon-plus'></i> " . $lang->mr->create, '', "class='btn btn-info'");?>
<?php endif;?>
</p>
</div>
</div>
<?php else:?>
<div class="btn-toolbar pull-left">
<?php echo html::a($this->createLink('mr', 'browse'), '<i class="icon icon-back icon-sm"></i> ' . $lang->goback, '', "class='btn btn-secondary'");?>
<div class="divider"></div>
<div class="page-title">
<span class="label label-id"><?php echo $MR->id?></span>
<span class="text" title='<?php echo $MR->title;?>' style='color: blue'><?php echo html::a($rawMR->web_url, $MR->title, "_blank", "class='btn btn-link btn-active-text' style='color: blue'");?></span>
</div>
</div>
<div id="mainContent" class="main-row">
<div class="main-col">
<div class="cell">
<div class="detail">
<div class="detail-title"><?php echo $lang->mr->description;?></div>
<div class="detail-content article-content">
<?php echo !empty($MR->description) ? $MR->description : "<div class='text-center text-muted'>" . $lang->noData . '</div>';?>
</div>
</div>
</div>
<div class="cell">
<div><?php echo $lang->mr->from . html::a($sourceProjectURL, $sourceProjectName . ":" . $MR->sourceBranch, "_blank", "class='btn btn-link btn-active-text' style='color: blue'") . $lang->mr->to . html::a($targetProjectURL, $targetProjectName . ":" . $MR->targetBranch, "_blank", "class='btn btn-link btn-active-text' style='color: blue'");?></div>
<div><?php if(isset($rawMR->head_pipeline->status)) echo $lang->mr->pipeline . $lang->mr->status . ": " . zget($lang->mr->pipelineStatus, $rawMR->head_pipeline->status, $lang->mr->pipelineUnknown);?></div>
<div><?php echo $lang->mr->mergeStatus . ": " . zget($lang->mr->mergeStatusList, $rawMR->merge_status);?></div>
<div><?php echo $lang->mr->MRHasConflicts . ": " . ($rawMR->has_conflicts ? $lang->mr->hasConflicts : $lang->mr->hasNoConflict);?></div>
</div>
<div class="cell"><?php echo sprintf($lang->mr->commandDocument, $httpRepoURL, $MR->sourceBranch, $branchPath, $MR->targetBranch, $branchPath, $MR->targetBranch);?></div>
</div>
</div>
<?php endif;?>
<?php include '../../common/view/footer.html.php';?>