diff --git a/lib/scm/gitfox.class.php b/lib/scm/gitfox.class.php index 18ebd69810..553f58e9fa 100644 --- a/lib/scm/gitfox.class.php +++ b/lib/scm/gitfox.class.php @@ -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); diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php index f82bf01b25..cb74901e89 100644 --- a/lib/scm/gitlab.class.php +++ b/lib/scm/gitlab.class.php @@ -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); diff --git a/module/gitfox/model.php b/module/gitfox/model.php index b04b6e0d2b..e0c4c84f41 100644 --- a/module/gitfox/model.php +++ b/module/gitfox/model.php @@ -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')); - } } - diff --git a/module/repo/control.php b/module/repo/control.php index abe8be0190..dadf750118 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -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); } diff --git a/module/repo/model.php b/module/repo/model.php index 5670a76068..3f86f317c0 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -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));