* Adjust params type.
This commit is contained in:
+1
-4
@@ -32,9 +32,6 @@ class ciModel extends model
|
||||
{
|
||||
$repo = $this->loadModel('repo')->getByID($this->session->repoID);
|
||||
if(!empty($repo) and !in_array(strtolower($repo->SCM), $this->config->repo->gitServiceList)) unset($this->lang->devops->menu->mr);
|
||||
|
||||
$tab = $this->app->tab;
|
||||
$repos = $this->repo->getRepoPairs($tab);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +315,7 @@ class ciModel extends model
|
||||
public function sendRequest($url, $data, $userPWD = '')
|
||||
{
|
||||
if(!empty($data->PARAM_TAG)) $data->PARAM_REVISION = '';
|
||||
$response = common::http($url, $data, array(CURLOPT_HEADER => true, CURLOPT_USERPWD => $userPWD));
|
||||
$response = common::http($url, (array)$data, array(CURLOPT_HEADER => true, CURLOPT_USERPWD => $userPWD));
|
||||
if(preg_match("!Location: .*item/(.*)/!", $response, $matches)) return $matches[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
+10
-10
@@ -1724,20 +1724,20 @@ class commonModel extends model
|
||||
/**
|
||||
* Http.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string|array $data
|
||||
* @param array $options This is option and value pair, like CURLOPT_HEADER => true. Use curl_setopt function to set options.
|
||||
* @param array $headers Set request headers.
|
||||
* @param string $dataType
|
||||
* @param string $method POST|PATCH|PUT
|
||||
* @param int $timeout
|
||||
* @param bool $httpCode Return a array contains response, http code, body, header. such as [response, http_code, 'body' => body, 'header' => header].
|
||||
* @param bool $log Save to log or not
|
||||
* @param string $url
|
||||
* @param string|array|object $data
|
||||
* @param array $options This is option and value pair, like CURLOPT_HEADER => true. Use curl_setopt function to set options.
|
||||
* @param array $headers Set request headers.
|
||||
* @param string $dataType
|
||||
* @param string $method POST|PATCH|PUT
|
||||
* @param int $timeout
|
||||
* @param bool $httpCode Return a array contains response, http code, body, header. such as [response, http_code, 'body' => body, 'header' => header].
|
||||
* @param bool $log Save to log or not
|
||||
* @static
|
||||
* @access public
|
||||
* @return string|array
|
||||
*/
|
||||
public static function http(string $url, string|array|null $data = null, array $options = array(), array $headers = array(), string $dataType = 'data', string $method = 'POST', int $timeout = 30, bool $httpCode = false, bool $log = true): string|array
|
||||
public static function http(string $url, string|array|object|null $data = null, array $options = array(), array $headers = array(), string $dataType = 'data', string $method = 'POST', int $timeout = 30, bool $httpCode = false, bool $log = true): string|array
|
||||
{
|
||||
global $lang, $app;
|
||||
if(!extension_loaded('curl'))
|
||||
|
||||
@@ -337,6 +337,7 @@ class mr extends control
|
||||
$this->app->loadLang('productplan');
|
||||
$this->view->title = $this->lang->mr->view;
|
||||
$this->view->MR = $MR;
|
||||
$this->view->repoID = $MR->repoID;
|
||||
$this->view->rawMR = isset($rawMR) ? $rawMR : false;
|
||||
$this->view->actions = $this->loadModel('action')->getList('mr', $MRID);
|
||||
$this->view->compile = $this->loadModel('compile')->getById($MR->compileID);
|
||||
@@ -814,7 +815,7 @@ class mr extends control
|
||||
$targetProject = $this->post->targetProject;
|
||||
$targetBranch = $this->post->targetBranch;
|
||||
|
||||
$result = $this->mr->checkSameOpened($hostID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
$result = $this->mr->checkSameOpened($hostID, (string)$sourceProject, $sourceBranch, (string)$targetProject, $targetBranch);
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -216,7 +216,7 @@ class mrModel extends model
|
||||
*/
|
||||
public function create(object $MR): array
|
||||
{
|
||||
$result = $this->checkSameOpened($MR->hostID, $MR->sourceProject, $MR->sourceBranch, $MR->targetProject, $MR->targetBranch);
|
||||
$result = $this->checkSameOpened($MR->hostID, (string)$MR->sourceProject, $MR->sourceBranch, (string)$MR->targetProject, $MR->targetBranch);
|
||||
if($result['result'] == 'fail') return $result;
|
||||
|
||||
$this->createMR($MR);
|
||||
@@ -225,7 +225,7 @@ class mrModel extends model
|
||||
$MRID = $this->dao->lastInsertId();
|
||||
$this->loadModel('action')->create('mr', $MRID, 'opened');
|
||||
|
||||
$rawMR = $this->apiCreateMR($this->post->hostID, $this->post->sourceProject, $MR);
|
||||
$rawMR = $this->apiCreateMR($MR->hostID, (string)$MR->sourceProject, $MR);
|
||||
|
||||
/**
|
||||
* Another open merge request already exists for this source branch.
|
||||
@@ -345,7 +345,7 @@ class mrModel extends model
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->checkSameOpened($MR->hostID, $MR->sourceProject, $MR->sourceBranch, $MR->targetProject, $MR->targetBranch);
|
||||
$result = $this->checkSameOpened($MR->hostID, (string)$MR->sourceProject, $MR->sourceBranch, (string)$MR->targetProject, $MR->targetBranch);
|
||||
if($result['result'] == 'fail')
|
||||
{
|
||||
dao::$errors[] = $result['message'];
|
||||
@@ -532,12 +532,12 @@ class mrModel extends model
|
||||
*
|
||||
* @link https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
|
||||
* @param int $hostID
|
||||
* @param int $projectID
|
||||
* @param string $projectID
|
||||
* @param object $MR
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiCreateMR(int $hostID, int $projectID, object $MR): object
|
||||
public function apiCreateMR(int $hostID, string $projectID, object $MR): object
|
||||
{
|
||||
$host = $this->loadModel('pipeline')->getByID($hostID);
|
||||
|
||||
@@ -715,9 +715,9 @@ class mrModel extends model
|
||||
* @param string $projectID targetProject
|
||||
* @param int $MRID
|
||||
* @access public
|
||||
* @return object
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetMRCommits(int $hostID, string $projectID, int $MRID): object
|
||||
public function apiGetMRCommits(int $hostID, string $projectID, int $MRID): array
|
||||
{
|
||||
$host = $this->loadModel('pipeline')->getByID($hostID);
|
||||
if($host->type == 'gitlab')
|
||||
@@ -926,9 +926,9 @@ class mrModel extends model
|
||||
* @param object $MR
|
||||
* @param string $encoding
|
||||
* @access public
|
||||
* @return object
|
||||
* @return array
|
||||
*/
|
||||
public function getDiffs(object $MR, string $encoding = ''): object
|
||||
public function getDiffs(object $MR, string $encoding = ''): array
|
||||
{
|
||||
$repo = $this->loadModel('repo')->getByID($MR->repoID);
|
||||
if(!$repo) return array();
|
||||
@@ -1004,9 +1004,9 @@ class mrModel extends model
|
||||
* @param string $projectID
|
||||
* @param int $MRID
|
||||
* @access public
|
||||
* @return object
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetDiffVersions(int $hostID, string $projectID, int $MRID): object
|
||||
public function apiGetDiffVersions(int $hostID, string $projectID, int $MRID): array
|
||||
{
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($hostID), "/projects/$projectID/merge_requests/$MRID/versions");
|
||||
return json_decode(commonModel::http($url));
|
||||
@@ -1019,11 +1019,11 @@ class mrModel extends model
|
||||
* @param int $hostID
|
||||
* @param string $projectID
|
||||
* @param int $MRID
|
||||
* @param string $versionID
|
||||
* @param int $versionID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiGetSingleDiffVersion(int $hostID, string $projectID, int $MRID, string $versionID): object
|
||||
public function apiGetSingleDiffVersion(int $hostID, string $projectID, int $MRID, int $versionID): object
|
||||
{
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($hostID), "/projects/$projectID/merge_requests/$MRID/versions/$versionID");
|
||||
return json_decode(commonModel::http($url));
|
||||
@@ -1277,7 +1277,7 @@ class mrModel extends model
|
||||
public function linkObjects(object $MR): bool
|
||||
{
|
||||
/* Get commits by MR. */
|
||||
$commits = $this->apiGetMRCommits($MR->hostID, $MR->targetProject, $MR->mriid);
|
||||
$commits = $this->apiGetMRCommits($MR->hostID, (string)$MR->targetProject, $MR->mriid);
|
||||
if(empty($commits)) return true;
|
||||
|
||||
/* Init objects. */
|
||||
@@ -1435,7 +1435,7 @@ class mrModel extends model
|
||||
->fetch('id');
|
||||
if(!empty($dbOpenedID)) return array('result' => 'fail', 'message' => sprintf($this->lang->mr->hasSameOpenedMR, $dbOpenedID));
|
||||
|
||||
$MR = $this->apiGetSameOpened($hostID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
$MR = $this->apiGetSameOpened($hostID, (string)$sourceProject, $sourceBranch, (string)$targetProject, $targetBranch);
|
||||
if($MR) return array('result' => 'fail', 'message' => sprintf($this->lang->mr->errorLang[2], $MR->iid));
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user