From aa07506688bfa50a66f10e0dd78ba9e84a8eccad Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 9 Mar 2020 09:13:24 +0800 Subject: [PATCH] * adjust for compile each tag. --- module/git/model.php | 18 +++++++++++++----- module/svn/model.php | 20 ++++++++++++++------ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/module/git/model.php b/module/git/model.php index 37c616eb54..38c9ced53f 100644 --- a/module/git/model.php +++ b/module/git/model.php @@ -148,14 +148,22 @@ class gitModel extends model $jobs = zget($tagGroup, $repoID, array()); foreach($jobs as $job) { - $tags = $this->getRepoTags($repo); - end($tags); - $lastTag = current($tags); - if($lastTag != $job->lastTag) + $tags = $this->getRepoTags($repo); + $isNew = false; + $lastTag = ''; + foreach($tags as $tag) { + if($tag == $job->lastTag) + { + $isNew = true; + continue; + } + if(!$isNew) continue; + + $lastTag = $tag; $this->compile->createByJob($job->id, $lastTag, 'tag'); - $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec(); } + if($lastTag) $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec(); } } } diff --git a/module/svn/model.php b/module/svn/model.php index cafd9ec7b8..6ec9e7cadb 100644 --- a/module/svn/model.php +++ b/module/svn/model.php @@ -139,15 +139,23 @@ class svnModel extends model $jobs = zget($tagGroup, $repoID, array()); foreach($jobs as $job) { - $dirs = $this->getRepoTags($repo, $job->svnDir); - end($dirs); - $lastTag = current($dirs); - if($lastTag != $job->lastTag) + $dirs = $this->getRepoTags($repo, $job->svnDir); + $isNew = false; + $lastTag = ''; + foreach($dirs as $dir) { - $tag = rtrim($repo->path , '/') . '/' . trim($job->svnDir, '/') . '/' . $lastTag; + if($dir == $job->lastTag) + { + $isNew = true; + continue; + } + if(!$isNew) continue; + + $lastTag = $dir; + $tag = rtrim($repo->path , '/') . '/' . trim($job->svnDir, '/') . '/' . $lastTag; $this->compile->createByJob($job->id, $tag, 'tag'); - $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec(); } + if($lastTag) $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec(); } } }