* Adjust mr merge logic for gitfox.
This commit is contained in:
@@ -943,7 +943,7 @@ class gitfoxRepo
|
||||
$MR->id = $MR->number;
|
||||
$MR->iid = $MR->number;
|
||||
$MR->state = $MR->state == 'open' ? 'opened' : $MR->state;
|
||||
$MR->merge_status = $MR->merge_check_status ? 'cannot_be_merged' : 'can_be_merged';
|
||||
$MR->merge_status = $MR->merge_check_status != 'mergeable' ? 'cannot_be_merged' : 'can_be_merged';
|
||||
$MR->changes_count = $MR->stats->commits;
|
||||
$MR->source_project_id = $MR->source_repo_id;
|
||||
$MR->target_project_id = $MR->target_repo_id;
|
||||
|
||||
@@ -558,4 +558,25 @@ class gitfoxModel extends model
|
||||
|
||||
return $matchedUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过API删除GitFox分支。
|
||||
* Api delete branch.
|
||||
*
|
||||
* @param int $gitfoxID
|
||||
* @param string $project
|
||||
* @param string $branch
|
||||
* @access public
|
||||
* @return object|null
|
||||
*/
|
||||
public function apiDeleteBranch(int $gitfoxID, string $project, string $branch): object|null
|
||||
{
|
||||
if(empty($branch) || empty($project)) return null;
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitfoxID);
|
||||
$url = sprintf($apiRoot->url, "/repos/$project/branches/$branch");
|
||||
if(!$url) return null;
|
||||
|
||||
return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'DELETE'), $apiRoot->header));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +70,11 @@ $config->mr->actionList['delete']['className'] = 'ajax-submit';
|
||||
$config->mr->actionList['delete']['data-app'] = $app->tab;
|
||||
|
||||
$config->mr->actionList['accept'] = array();
|
||||
$config->mr->actionList['accept']['icon'] = 'flow';
|
||||
$config->mr->actionList['accept']['text'] = $lang->mr->acceptMR;
|
||||
$config->mr->actionList['accept']['url'] = helper::createLink('mr', 'accept', "MRID={id}");
|
||||
$config->mr->actionList['accept']['data-app'] = $app->tab;
|
||||
$config->mr->actionList['accept']['icon'] = 'flow';
|
||||
$config->mr->actionList['accept']['text'] = $lang->mr->acceptMR;
|
||||
$config->mr->actionList['accept']['url'] = helper::createLink('mr', 'accept', "MRID={id}");
|
||||
$config->mr->actionList['accept']['data-app'] = $app->tab;
|
||||
$config->mr->actionList['accept']['className'] = 'ajax-submit';
|
||||
|
||||
$config->mr->actionList['approval'] = array();
|
||||
$config->mr->actionList['approval']['icon'] = 'ok';
|
||||
|
||||
+17
-12
@@ -805,22 +805,27 @@ 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' : 'merege');
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = sprintf($apiRoot, "/repos/$MR->targetProject/pulls/$MR->mriid/merge");
|
||||
$merge = $MR->squash == '1' ? 'squash' : 'merge';
|
||||
$data = array('Do' => $merge);
|
||||
$url = sprintf($apiRoot, "/repos/$MR->targetProject/pulls/$MR->mriid/merge");
|
||||
$data = array('Do' => $MR->squash == '1' ? 'squash' : 'merge');
|
||||
if($MR->removeSourceBranch == '1') $data['delete_branch_after_merge'] = true;
|
||||
|
||||
$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') $this->loadModel('gogs')->apiDeleteBranch($MR->hostID, $MR->targetProject, $MR->sourceBranch);
|
||||
}
|
||||
|
||||
return $rowMR;
|
||||
}
|
||||
|
||||
$rowMR = json_decode(commonModel::http($url, $data, array(), $host->type == 'gitfox' ? $apiRoot->header : 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);
|
||||
}
|
||||
|
||||
return $rowMR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user