test and fix cron issue

This commit is contained in:
aaronchen2k
2020-01-16 10:20:26 +08:00
parent f32d591d7e
commit 2ce41370aa
3 changed files with 13 additions and 21 deletions
+7 -15
View File
@@ -87,11 +87,9 @@ class gitModel extends model
$this->setLogRoot();
$this->setRestartFile();
foreach($this->repos as $name => $repo)
foreach($this->repos as $repo)
{
$this->printLog("begin repo $name");
$repo = (object)$repo;
$repo->name = $name;
$this->printLog("begin repo $repo->id");
if(!$this->setRepo($repo)) return false;
$this->pull();
@@ -140,9 +138,9 @@ class gitModel extends model
/**
* Pull codes from remote repo.
*
* @param $repoRoot
* @param $repo
*/
public function pull($repo)
public function pull($repo = '')
{
if (!empty($repo)) {
$repoRoot = $repo->path;
@@ -205,21 +203,15 @@ class gitModel extends model
$gitRepos = [];
$paths = [];
// 有了库管理,忽略配置里的库
foreach($repoObjs as $repoInDb)
{
if(strtolower($repoInDb->SCM) === 'git' && !in_array($repoInDb->path, $gitRepos)) {
$gitRepos[] = array(path => $repoInDb->path, encoding => 'utf-8');
$gitRepos[] = array(id=>$repoInDb->id, path => $repoInDb->path, encoding => 'utf-8');
$paths[] = $repoInDb->path;
}
}
foreach($this->config->git->repos as $repoInConfig)
{
if(!empty($repoInConfig['path']) && !in_array($repoInConfig['path'], $paths)) {
$gitRepos[] = $repoInConfig;
}
}
if(!$gitRepos)
{
echo "You must set one git repo.\n";
@@ -261,7 +253,7 @@ class gitModel extends model
$this->setClient($repo);
if(empty($this->client)) return false;
$this->setLogFile($repo->name);
$this->setLogFile($repo->id);
$this->setRepoRoot($repo);
return true;
}