* Finish task #113489.
This commit is contained in:
@@ -631,7 +631,7 @@ class gitfox
|
||||
|
||||
$param = new stdclass();
|
||||
$param->path = urldecode($path);
|
||||
$param->git_ref = ($toRevision != 'HEAD' and $toRevision) ? $toRevision : $this->branch;
|
||||
$param->git_ref = $toRevision ? $toRevision : $this->branch;
|
||||
|
||||
$fromDate = $beginDate ? $beginDate : $this->getCommittedDate($fromRevision);
|
||||
$toDate = $endDate ? $endDate : $this->getCommittedDate($toRevision);
|
||||
|
||||
@@ -688,7 +688,7 @@ class gitlab
|
||||
|
||||
$param = new stdclass();
|
||||
$param->path = urldecode($path);
|
||||
$param->ref_name = ($toRevision != 'HEAD' and $toRevision) ? $toRevision : $this->branch;
|
||||
$param->ref_name = $toRevision ? $toRevision : $this->branch;
|
||||
|
||||
$fromDate = $beginDate ? $beginDate : $this->getCommittedDate($fromRevision);
|
||||
$toDate = $endDate ? $endDate : $this->getCommittedDate($toRevision);
|
||||
|
||||
+2
-49
@@ -204,33 +204,14 @@ class gitfoxModel extends model
|
||||
if(!isset($hook->url)) return false;
|
||||
|
||||
$newHook = new stdclass;
|
||||
$newHook->insecure = "false"; /* Disable ssl verification for every hook. */
|
||||
$newHook->insecure = true; /* Disable ssl verification for every hook. */
|
||||
|
||||
foreach($hook as $index => $item) $newHook->$index= $item;
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitfoxID);
|
||||
$url = sprintf($apiRoot->url, "/repos/{$repoID}/webhooks");
|
||||
|
||||
return json_decode(commonModel::http($url, $newHook, array(), $apiRoot->header));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过api删除hook。
|
||||
* Delete hook by api.
|
||||
*
|
||||
* @param int $gitfoxID
|
||||
* @param int $repoID
|
||||
* @param int $hookID
|
||||
* @access public
|
||||
* @link https://docs.gitfox.com/ee/api/projects.html#delete-project-hook
|
||||
* @return object|array|null
|
||||
*/
|
||||
public function apiDeleteHook(int $gitfoxID, int $repoID, int $hookID): object|array|null
|
||||
{
|
||||
$apiRoot = $this->getApiRoot($gitfoxID, false);
|
||||
$url = sprintf($apiRoot->url, "/repos/{$repoID}/hooks/{$hookID}");
|
||||
|
||||
return json_decode(commonModel::http($url, array(), array(CURLOPT_CUSTOMREQUEST => 'DELETE'), $apiRoot->header));
|
||||
return json_decode(commonModel::http($url, $newHook, array(), $apiRoot->header, 'json'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,32 +262,4 @@ class gitfoxModel extends model
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过api更新hook。
|
||||
* Update hook by api.
|
||||
*
|
||||
* @param int $gitfoxID
|
||||
* @param int $projectID
|
||||
* @param int $hookID
|
||||
* @param object $hook
|
||||
* @access public
|
||||
* @link https://docs.gitfox.com/ee/api/projects.html#edit-project-hook
|
||||
* @return string|false
|
||||
*/
|
||||
public function apiUpdateHook(int $gitfoxID, int $projectID, int $hookID, object $hook): string|false
|
||||
{
|
||||
$apiRoot = $this->getApiRoot($gitfoxID, false);
|
||||
|
||||
if(!isset($hook->url)) return false;
|
||||
|
||||
$newHook = new stdclass;
|
||||
$newHook->enable_ssl_verification = "false"; /* Disable ssl verification for every hook. */
|
||||
|
||||
foreach($hook as $index => $item) $newHook->$index= $item;
|
||||
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/hooks/{$hookID}");
|
||||
return commonModel::http($url, $newHook, array(CURLOPT_CUSTOMREQUEST => 'PUT'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class repo extends control
|
||||
{
|
||||
/* Add webhook. */
|
||||
$repo = $this->repo->getByID($repoID);
|
||||
$this->loadModel($this->post->SCM)->updateCodePath($repo->serviceHost, $repo->serviceProject, $repo->id);
|
||||
$this->loadModel($this->post->SCM)->updateCodePath($repo->serviceHost, (int)$repo->serviceProject, (int)$repo->id);
|
||||
$this->repo->updateCommitDate($repoID);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,10 +193,10 @@ class repoModel extends model
|
||||
$repoID = $this->dao->lastInsertID();
|
||||
|
||||
$repo = $this->getByID($repoID);
|
||||
if($repo->SCM == 'Gitlab')
|
||||
if(in_array($repo->SCM, $this->config->repo->notSyncSCM))
|
||||
{
|
||||
$token = uniqid();
|
||||
$res = $this->loadModel('gitlab')->addPushWebhook($repo, $token);
|
||||
$res = $this->loadModel($repo->SCM)->addPushWebhook($repo, $token);
|
||||
if($res !== true)
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_REPO)->where('id')->eq($repoID)->exec();
|
||||
@@ -2411,8 +2411,8 @@ class repoModel extends model
|
||||
{
|
||||
$scm = $this->app->loadClass('scm');
|
||||
$scm->setEngine($repo);
|
||||
$commits = $scm->engine->getCommitsByPath('', '', '', 1, 1);
|
||||
$commitDate = $repo->SCM == 'GitLab' ? $commits[0]->committed_date : $commits[0]->author->when;
|
||||
$commits = $scm->engine->getCommitsByPath('', '', 'HEAD', 1, 1);
|
||||
$commitDate = $repo->SCM == 'Gitlab' ? $commits[0]->committed_date : $commits[0]->author->when;
|
||||
if($commits && !empty($commitDate))
|
||||
{
|
||||
$lastCommitDate = date('Y-m-d H:i:s', strtotime($commitDate));
|
||||
|
||||
Reference in New Issue
Block a user