* finish task #6953.

This commit is contained in:
wangyidong
2020-03-04 15:07:49 +08:00
parent 94f8bf2dfc
commit b9d709ccc4
11 changed files with 144 additions and 108 deletions
+49 -3
View File
@@ -142,6 +142,21 @@ class svnModel extends model
$integrations = zget($objects, 'integrations', array());
$this->loadModel('compile');
foreach($integrations as $id) $this->compile->createByIntegration($id);
/* Create compile by tag. */
$integrations = $this->dao->select('*')->from(TABLE_INTEGRATION)->where('triggerType')->eq('tag')->andWhere('repo')->eq($repo->id)->fetchAll('id');
foreach($integrations as $integration)
{
$dirs = $this->getRepoTags($repo, $integration->svnDir);
end($dirs);
$lastTag = current($dirs);
if($lastTag != $integration->lastTag)
{
$tag = rtrim($repo->path , '/') . '/' . trim($integration->svnDir, '/') . '/' . $lastTag;
$this->compile->createByIntegration($integration->id, $tag, 'tag');
$this->dao->update(TABLE_INTEGRATION)->set('lastTag')->eq($lastTag)->where('id')->eq($integration->id)->exec();
}
}
}
}
@@ -316,9 +331,40 @@ class svnModel extends model
*/
public function getRepoTags($repo, $path)
{
$scm = $this->app->loadClass('scm');
$scm->setEngine($repo);
return $scm->tags($path);
$parent = '/';
if($repo->prefix) $parent = rtrim($repo->prefix, '/');
if(trim($path, '/')) $parent = rtrim($repo->prefix, '/') . '/' . trim($path, '/');
$stmt = $this->dao->select('t1.*,t2.revision as svnRevision,t2.time')->from(TABLE_REPOFILES)->alias('t1')
->leftJoin(TABLE_REPOHISTORY)->alias('t2')->on('t1.revision = t2.id')
->where('t1.repo')->eq($repo->id)
->andWhere('t1.type')->eq('dir')
->andWhere('t1.parent')->eq($parent)
->orderBy('path,svnRevision,time')
->query();
$dirs = array();
while($row = $stmt->fetch())
{
$path = $row->path;
if($repo->prefix) $path = str_replace($repo->prefix, '', $path);
if(empty($path)) $path = '/';
$dirs[$path] = $row;
if($row->action == 'D') unset($dirs[$path]);
}
$dirTime = array();
foreach($dirs as $dirPath => $dir) $dirTime[$dir->time][$dirPath] = $dirPath;
ksort($dirTime);
$dirPairs = array();
foreach($dirTime as $time => $dirPaths)
{
ksort($dirPaths);
foreach($dirPaths as $dirPath) $dirPairs[$dirPath] = basename($dirPath);
}
return $dirPairs;
}
/**