+ Add user info for scm create branch.
This commit is contained in:
@@ -188,12 +188,16 @@ class Gitea
|
||||
*/
|
||||
public function createBranch($branchName = '', $ref = 'master')
|
||||
{
|
||||
chdir($this->root);
|
||||
$res = execCmd(escapeCmd("{$this->client} checkout -b {$branchName} origin/{$ref}"), 'array');
|
||||
if(empty($res[0])) return array('result' => 'fail', 'message' => 'Branch is exists.');
|
||||
global $app;
|
||||
$project = $app->control->loadModel('gitea')->getApiRoot($this->repo->serviceHost);
|
||||
|
||||
execCmd(escapeCmd("{$this->client} push origin {$branchName}"), 'array');
|
||||
return array('result' => 'success', 'message' => '');
|
||||
$url = sprintf($apiRoot, "/repos/{$this->repo->serviceProject}/branches");
|
||||
$param = new stdclass();
|
||||
$param->old_branch_name = $ref;
|
||||
$param->new_branch_name = $branchName;
|
||||
$result = json_decode(commonModel::http($url), $param);
|
||||
|
||||
return array('result' => empty($result->name) ? 'fail' : 'success', 'message' => zget($result, 'message', 'Error'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ class gitlab
|
||||
$this->root = rtrim($root, '/') . '/';
|
||||
$this->token = $password;
|
||||
$this->branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : 'HEAD';
|
||||
$this->repo = $repo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,12 +210,13 @@ class gitlab
|
||||
*/
|
||||
public function createBranch($branchName = '', $ref = 'master')
|
||||
{
|
||||
global $app;
|
||||
|
||||
$param = new stdclass();
|
||||
$param->ref = $ref;
|
||||
$param->branch = $branchName;
|
||||
$result = $app->control->loadModel('gitlab')->apiCreateBranch($this->repo->serviceHost, $this->repo->serviceProject, $param);
|
||||
|
||||
$api = $this->root . 'branches?private_token=' . $this->token;
|
||||
$result = json_decode(commonModel::http($api, $param));
|
||||
return array('result' => empty($result->name) ? 'fail' : 'success', 'message' => $result->message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user