- [task#120961,0.5h] delete unused code for mr.

This commit is contained in:
caoyanyi
2024-06-19 16:32:25 +08:00
committed by 田淑杰
parent 98ceb03d7f
commit c1d8240a16
+3 -27
View File
@@ -574,14 +574,6 @@ class mrModel extends model
$url = sprintf($apiRoot, "/projects/{$oldMR->sourceProject}/merge_requests/{$oldMR->mriid}");
return json_decode(commonModel::http($url, $MRObject, array(CURLOPT_CUSTOMREQUEST => 'PUT')));
}
elseif($host->type == 'gitfox')
{
if(isset($MR->description)) $MRObject->description = $MR->description;
$url = sprintf($apiRoot->url, "/repos/{$oldMR->sourceProject}/pullreq/{$oldMR->mriid}");
$mergeResult = json_decode(commonModel::http($url, $MRObject, array(), $apiRoot->header, 'json', 'PATCH'));
if(isset($mergeResult->number)) $mergeResult->id = $mergeResult->number;
return $mergeResult;
}
else
{
if(isset($MR->targetBranch)) $MRObject->base = zget($MR, 'targetBranch', $oldMR->targetBranch);
@@ -638,8 +630,7 @@ class mrModel extends model
if(is_object($apiRoot)) $apiRoot = $apiRoot->url;
$api = "/repos/$projectID/pulls/$MRID";
if($host->type == 'gitfox') $api = "/repos/$projectID/pullreq/$MRID/state";
return json_decode(commonModel::http(sprintf($apiRoot, $api), array('state' => 'closed'), array(), $header, 'json', $host->type == 'gitfox' ? 'POST' : 'PATCH'));
return json_decode(commonModel::http(sprintf($apiRoot, $api), array('state' => 'closed'), array(), $header, 'json', 'PATCH'));
}
return null;
@@ -692,11 +683,6 @@ class mrModel extends model
$url = sprintf($apiRoot, "/projects/$projectID/merge_requests/$MRID") . '&state_event=reopen';
return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'PUT')));
}
elseif($host->type == 'gitfox')
{
$url = sprintf($apiRoot->url, "/repos/$projectID/pullreq/$MRID/state");
return json_decode(commonModel::http($url, array('state' => 'open'), array(), $apiRoot->header, 'json'));
}
else
{
$url = sprintf($apiRoot, "/repos/$projectID/pulls/$MRID");
@@ -726,12 +712,6 @@ class mrModel extends model
$url = sprintf($apiRoot, "/projects/$MR->targetProject/merge_requests/$MR->mriid/merge");
return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'PUT')));
}
elseif($host->type == 'gitfox')
{
$rowMR = $this->apiGetSingleMR($MR->repoID, $MR->mriid);
$url = sprintf($apiRoot->url, "/repos/$MR->targetProject/pullreq/$MR->mriid/merge");
$data = array('dry_run' => false, 'bypass_rules' => false, 'source_sha' => $rowMR->source_sha, 'method' => $MR->squash == '1' ? 'squash' : 'merge');
}
else
{
$url = sprintf($apiRoot, "/repos/$MR->targetProject/pulls/$MR->mriid/merge");
@@ -739,11 +719,11 @@ class mrModel extends model
if($MR->removeSourceBranch == '1') $data['delete_branch_after_merge'] = true;
}
$rowMR = json_decode(commonModel::http($url, $data, array(), $host->type == 'gitfox' ? $apiRoot->header : array(), 'json', 'POST'));
$rowMR = json_decode(commonModel::http($url, $data, array(), array(), 'json', 'POST'));
if(!isset($rowMR->massage))
{
$rowMR = $this->apiGetSingleMR($MR->repoID, $MR->mriid);
if($MR->removeSourceBranch == '1' && in_array($host->type, array('gogs', 'gitfox'))) $this->loadModel($host->type)->apiDeleteBranch($MR->hostID, $MR->sourceProject, $MR->sourceBranch);
if($MR->removeSourceBranch == '1' && $host->type == 'gogs') $this->loadModel($host->type)->apiDeleteBranch($MR->hostID, $MR->sourceProject, $MR->sourceBranch);
}
return $rowMR;
@@ -791,10 +771,6 @@ class mrModel extends model
}
}
}
elseif($host->type == 'gitfox')
{
$lines = $scm->diff('', $MR->targetBranch, $MR->sourceBranch, 'isBranchOrTag');
}
else
{
$lines = $this->apiGetDiffs($MR->hostID, $MR->targetProject, $MR->mriid);