diff --git a/module/mr/lang/en.php b/module/mr/lang/en.php index 8cb69dabec..019404c9d9 100644 --- a/module/mr/lang/en.php +++ b/module/mr/lang/en.php @@ -105,7 +105,7 @@ $lang->mr->apiError->createMR = "Failed to create a merge request through API. R $lang->mr->apiError->sudo = "Unable to operate with the GitLab account bound to the current user. Reason: %s"; $lang->mr->createFailedFromAPI = "Failed to create Merge Request."; -$lang->mr->hasSameOpenedMR = "There are duplicate and unclosed merge requests."; +$lang->mr->hasSameOpenedMR = "There are duplicate and unclosed merge requests: ID%u"; $lang->mr->accessGitlabFailed = "Unable to connect to the GitLab server."; $lang->mr->reopenSuccess = "The merge request was reopened."; $lang->mr->closeSuccess = "Merge request closed."; diff --git a/module/mr/lang/zh-cn.php b/module/mr/lang/zh-cn.php index 1bed150255..67f96552f8 100644 --- a/module/mr/lang/zh-cn.php +++ b/module/mr/lang/zh-cn.php @@ -105,7 +105,7 @@ $lang->mr->apiError->createMR = "通过API创建合并请求失败,失败原 $lang->mr->apiError->sudo = "无法以当前用户绑定的GitLab账户进行操作,失败原因:%s"; $lang->mr->createFailedFromAPI = "创建合并请求失败。"; -$lang->mr->hasSameOpenedMR = "存在重复并且未关闭的合并请求。"; +$lang->mr->hasSameOpenedMR = "存在重复并且未关闭的合并请求: ID%u"; $lang->mr->accessGitlabFailed = "当前无法连接到GitLab服务器。"; $lang->mr->reopenSuccess = "已重新打开合并请求。"; $lang->mr->closeSuccess = "已关闭合并请求。"; diff --git a/module/mr/model.php b/module/mr/model.php index 5551eaf3a9..83863e4ebf 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -1462,7 +1462,7 @@ class mrModel extends model { if(empty($sourceProject) or empty($sourceBranch) or empty($targetProject) or empty($targetBranch)) return array('result' => 'success'); - $dbOpenedCount = $this->dao->select('count(*) as count')->from(TABLE_MR) + $dbOpenedID = $this->dao->select('id')->from(TABLE_MR) ->where('gitlabID')->eq($gitlabID) ->andWhere('sourceProject')->eq($sourceProject) ->andWhere('sourceBranch')->eq($sourceBranch) @@ -1470,10 +1470,11 @@ class mrModel extends model ->andWhere('targetBranch')->eq($targetBranch) ->andWhere('status')->eq('opened') ->andWhere('deleted')->eq('0') - ->fetch('count'); - if($dbOpenedCount > 0) return array('result' => 'fail', 'message' => $this->lang->mr->hasSameOpenedMR); + ->fetch('id'); + if(!empty($dbOpenedID)) return array('result' => 'fail', 'message' => sprintf($this->lang->mr->hasSameOpenedMR, $dbOpenedID)); - if($this->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch)) return array('result' => 'fail', 'message' => $this->lang->mr->hasSameOpenedMR); + $mr = $this->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch); + if($mr) return array('result' => 'fail', 'message' => sprintf($this->lang->mr->errorLang[2], $mr->iid)); return array('result' => 'success'); }