diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php index ecf9871531..aad2bbb639 100644 --- a/lib/scm/gitlab.class.php +++ b/lib/scm/gitlab.class.php @@ -501,7 +501,8 @@ class gitlab if($version) { $lastCommit = $this->getSingleCommit($version); - if(empty($lastCommit)) return array(); + if(!isset($lastCommit->committed_date)) return array('commits' => array(), 'files' => array()); + $params['until'] = $lastCommit->committed_date; } @@ -644,7 +645,13 @@ class gitlab $api = ltrim($api, '/'); $api = $this->root . $api . '?' . http_build_query($params); - $response = file_get_contents($api); + $response = commonModel::http($api); + if(!empty(commonModel::$requestErrors)) + { + commonModel::$requestErrors = array(); + return array(); + } + return json_decode($response); } diff --git a/module/repo/control.php b/module/repo/control.php index 9580fd9d4f..411c1b0bc5 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -867,7 +867,7 @@ class repo extends control set_time_limit(0); $repo = $this->repo->getRepoByID($repoID); if(empty($repo)) die(); - //if($repo->synced) die('finish'); + if($repo->synced) die('finish'); $this->commonAction($repoID); $this->scm->setEngine($repo); diff --git a/module/repo/model.php b/module/repo/model.php index fd22ec2338..03ec69715a 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -281,15 +281,18 @@ class repoModel extends model $repo = $this->getRepoByID($id); $data = fixer::input('post') + ->setIf($this->post->SCM == 'Gitlab', 'password', $this->post->gitlabToken) + ->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost) + ->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject) ->setDefault('client', 'svn') ->setDefault('prefix', $repo->prefix) ->setDefault('product', '') - ->setIF($this->post->path != $repo->path, 'synced', 0) ->skipSpecial('path,client,account,password') ->join('product', ',') ->get(); if($this->post->SCM == 'Gitlab') $data->path = sprintf($this->config->repo->gitlab->apiPath, $data->gitlabHost, $this->post->gitlabProject); + if($data->path != $repo->path) $data->synced = 0; $data->acl = empty($data->acl) ? '' : json_encode($data->acl); @@ -313,7 +316,7 @@ class repoModel extends model $this->dao->update(TABLE_REPO)->data($data, $skip = 'gitlabHost,gitlabToken,gitlabProject') ->batchCheck($this->config->repo->edit->requiredFields, 'notempty') ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') - ->checkIF($data->SCM == 'GitLab', 'gitlabProject', 'notempty') + ->checkIF($data->SCM == 'GitLab', 'extra', 'notempty') ->autoCheck() ->where('id')->eq($id)->exec();