diff --git a/db/update16.0.beta1.sql b/db/update16.0.beta1.sql index 0ad3e88553..102e159f6b 100644 --- a/db/update16.0.beta1.sql +++ b/db/update16.0.beta1.sql @@ -7,3 +7,5 @@ ALTER TABLE `zt_task` ADD `mr` mediumint(8) unsigned NOT NULL AFTER `repo`; ALTER TABLE `zt_bug` ADD `mr` mediumint(8) unsigned NOT NULL AFTER `repo`; UPDATE `zt_grouppriv` SET `method`='addReview' where `module`='mr' and `method`='addBug'; + +ALTER TABLE `zt_mr` ADD `removeSourceBranch` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `compileStatus`; diff --git a/module/mr/lang/en.php b/module/mr/lang/en.php index 5db8f01833..12a2d4cbb4 100644 --- a/module/mr/lang/en.php +++ b/module/mr/lang/en.php @@ -56,8 +56,9 @@ $lang->mr->approvalResultList = array(); $lang->mr->approvalResultList['approve'] = 'Approve'; $lang->mr->approvalResultList['reject'] = 'Reject'; -$lang->mr->needApproved = 'This MR should be approved before merge'; -$lang->mr->needCI = 'This MR should be passed CI before merge'; +$lang->mr->needApproved = 'This MR should be approved before merge'; +$lang->mr->needCI = 'This MR should be passed CI before merge'; +$lang->mr->removeSourceBranch = 'Delete source branch after merge'; $lang->mr->repeatedOperation = 'Do not repeat operations'; diff --git a/module/mr/lang/zh-cn.php b/module/mr/lang/zh-cn.php index 6ba9fcf536..c1fa29837c 100644 --- a/module/mr/lang/zh-cn.php +++ b/module/mr/lang/zh-cn.php @@ -56,8 +56,9 @@ $lang->mr->approvalResultList = array(); $lang->mr->approvalResultList['approve'] = '通过'; $lang->mr->approvalResultList['reject'] = '拒绝'; -$lang->mr->needApproved = '需要通过评审才能合并'; -$lang->mr->needCI = '需要通过构建才能合并'; +$lang->mr->needApproved = '需要通过评审才能合并'; +$lang->mr->needCI = '需要通过构建才能合并'; +$lang->mr->removeSourceBranch = '合并后删除源分支'; $lang->mr->repeatedOperation = '请勿重复操作'; diff --git a/module/mr/model.php b/module/mr/model.php index 76ed950a2f..d934f051b7 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -87,6 +87,7 @@ class mrModel extends model $MR = fixer::input('post') ->setDefault('jobID', 0) ->setDefault('repoID', 0) + ->setDefault('removeSourceBranch','0') ->setDefault('needCI', 0) ->add('createdBy', $this->app->user->account) ->add('createdDate', helper::now()) @@ -114,11 +115,12 @@ class mrModel extends model $MRID = $this->dao->lastInsertId(); $MRObject = new stdclass; - $MRObject->target_project_id = $MR->targetProject; - $MRObject->source_branch = $MR->sourceBranch; - $MRObject->target_branch = $MR->targetBranch; - $MRObject->title = $MR->title; - $MRObject->description = $MR->description; + $MRObject->target_project_id = $MR->targetProject; + $MRObject->source_branch = $MR->sourceBranch; + $MRObject->target_branch = $MR->targetBranch; + $MRObject->title = $MR->title; + $MRObject->description = $MR->description; + $MRObject->remove_source_branch = $MR->removeSourceBranch == '1' ? true : false; if($MR->assignee) { $gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($this->post->gitlabID, $MR->assignee); @@ -187,6 +189,7 @@ class mrModel extends model $MR = fixer::input('post') ->setDefault('jobID', 0) ->setDefault('repoID', 0) + ->setDefault('removeSourceBranch','0') ->setDefault('needCI', 0) ->setDefault('editedBy', $this->app->user->account) ->setDefault('editedDate', helper::now()) @@ -212,9 +215,10 @@ class mrModel extends model /* Update MR in GitLab. */ $newMR = new stdclass; - $newMR->title = $MR->title; - $newMR->description = $MR->description; - $newMR->target_branch = $MR->targetBranch; + $newMR->title = $MR->title; + $newMR->description = $MR->description; + $newMR->target_branch = $MR->targetBranch; + $newMR->remove_source_branch = $MR->removeSourceBranch == '1' ? true : false; if($MR->assignee) { $gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($oldMR->gitlabID, $MR->assignee); diff --git a/module/mr/view/create.html.php b/module/mr/view/create.html.php index 71b862c73b..c05f0cc6a5 100644 --- a/module/mr/view/create.html.php +++ b/module/mr/view/create.html.php @@ -55,6 +55,15 @@ devops->repo;?> + + mr->removeSourceBranch;?> + +
+ + +
+ + mr->needCI;?> diff --git a/module/mr/view/edit.html.php b/module/mr/view/edit.html.php index 4489aeb320..deeafe821f 100644 --- a/module/mr/view/edit.html.php +++ b/module/mr/view/edit.html.php @@ -69,6 +69,16 @@ devops->repo;?> repoID, "class='form-control chosen'");?> + + mr->removeSourceBranch;?> + +
+ removeSourceBranch== '1' ? 'checked' : '' ?> + name="removeSourceBranch" value="1" id="removeSourceBranch"> + +
+ + mr->needCI;?>