* Fix feedback#5175,5271

This commit is contained in:
zenggang
2024-03-11 02:23:08 +00:00
parent 5580338433
commit f7f5ed64bd
4 changed files with 63 additions and 7 deletions
+5 -2
View File
@@ -602,12 +602,12 @@ class Subversion
$path = '"' . $this->root . '"';
if(stripos($this->root, 'https') === 0 or stripos($this->root, 'svn') === 0)
{
$comments = str_replace("\\", "/", "$this->client log $count -v -r $version:0 --non-interactive --trust-server-cert-failures=cn-mismatch --trust-server-cert --no-auth-cache --xml $path");
$comments = str_replace("\\", "/", "$this->client log $count -v -r $version:HEAD --non-interactive --trust-server-cert-failures=cn-mismatch --trust-server-cert --no-auth-cache --xml $path");
if($this->svnVersion and version_compare($this->svnVersion, '1.9', '<')) $comments = str_replace("\\", "/", "$this->client log $count -v -r $version:0 --non-interactive --trust-server-cert --no-auth-cache --xml $path");
}
else
{
$comments = str_replace("\\", "/", "$this->client log $count -v -r $version:0 --no-auth-cache --xml $path");
$comments = str_replace("\\", "/", "$this->client log $count -v -r $version:HEAD --no-auth-cache --xml $path");
}
$comments = $this->replaceAuth(escapeCmd($comments));
$comments = execCmd($comments, 'string', $result);
@@ -638,6 +638,9 @@ class Subversion
$parsedFile->path = (string)$file;
$parsedFile->type = (string)$file['kind'];
$parsedFile->action = (string)$file['action'];
if(isset($file['copyfrom-path'])) $parsedFile->copyfromPath = (string)$file['copyfrom-path'];
if(isset($file['copyfrom-rev'])) $parsedFile->copyfromRev = (string)$file['copyfrom-rev'];
$logs['files'][$parsedLog->revision][] = $parsedFile;
}
}
+16 -4
View File
@@ -1293,6 +1293,8 @@ class repo extends control
public function ajaxSyncCommit($repoID = 0, $type = 'batch')
{
set_time_limit(0);
ini_set('memory_limit', '1024M');
$repo = $this->repo->getByID($repoID);
if(empty($repo)) return;
if($repo->synced) return print($this->config->repo->repoSyncLog->finish);
@@ -1374,17 +1376,27 @@ class repo extends control
$version = 1;
if($repo->SCM != 'Gitlab')
{
$latestInDB = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
$orderBy = $repo->SCM == 'Subversion' ? 'svnRevision desc' : 't1.time';
$latestInDB = $this->dao->select('t1.*,t1.revision*1 as svnRevision')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.repo')->eq($repoID)
->beginIF($repo->SCM == 'Git' and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->beginIF($repo->SCM == 'Gitlab' and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->orderBy('t1.time')
->beginIF($repo->SCM == 'Subversion')->andWhere('t1.time')->ne('1970-01-01 08:00:00')->fi()
->orderBy($orderBy)
->limit(1)
->fetch();
$version = empty($latestInDB) ? 1 : $latestInDB->commit + 1;
$revision = $version == 1 ? 'HEAD' : (in_array($repo->SCM, array('Git', 'Gitea', 'Gogs')) ? $latestInDB->commit : $latestInDB->revision);
if(in_array($repo->SCM, array('Git', 'Gitea', 'Gogs')))
{
$revision = $version == 1 ? 'HEAD' : $latestInDB->commit;
}
else
{
$revision = $version == 1 ? '0' : $latestInDB->revision;
}
if($type == 'batch')
{
$logs = $this->scm->getCommits($revision, $this->config->repo->batchNum, $branchID);
+13 -1
View File
@@ -422,7 +422,7 @@ class repoModel extends model
$this->updateCommitDate($repo->id);
}
if(($repo->serviceHost != $data->serviceHost || $repo->serviceProject != $data->serviceProject) && $repo->path != $data->path)
if(($repo->serviceHost != $data->serviceHost || $repo->serviceProject != $data->serviceProject || $data->SCM == 'Subversion') && $repo->path != $data->path)
{
$this->repoTao->deleteInfoByID($repo->id);
return false;
@@ -1153,6 +1153,11 @@ class repoModel extends model
{
$parentPath = dirname($file->path);
$copyfromPath = !empty($file->copyfromPath) ? $file->copyfromPath : '';
$copyfromRev = !empty($file->copyfromRev) ? $file->copyfromRev : '';
unset($file->copyfromPath);
unset($file->copyfromRev);
$file->parent = $parentPath == '\\' ? '/' : $parentPath;
$file->revision = $commitID;
$file->repo = $repoID;
@@ -1166,6 +1171,8 @@ class repoModel extends model
$file->action = 'D';
$this->dao->insert(TABLE_REPOFILES)->data($file)->exec();
}
if(!empty($copyfromPath) && !empty($copyfromRev)) $this->repoTao->copySvnDir($repoID, $copyfromPath, $copyfromRev, $file->path);
}
}
$revisionPairs[$commit->revision] = $commit->revision;
@@ -1215,6 +1222,9 @@ class repoModel extends model
{
$parentPath = dirname($file);
$copyfromPath = !empty($info['copyfrom-path']) ? $info['copyfrom-path'] : '';
$copyfromRev = !empty($info['copyfrom-rev']) ? $info['copyfrom-rev']: '';
$repoFile = new stdclass();
$repoFile->repo = $repoID;
$repoFile->revision = $commitID;
@@ -1236,6 +1246,8 @@ class repoModel extends model
$repoFile->oldPath = '';
$this->dao->insert(TABLE_REPOFILES)->data($repoFile)->exec();
}
if(!empty($copyfromPath) && !empty($copyfromRev)) $this->repoTao->copySvnDir($repoID, $copyfromPath, $copyfromRev, $repoFile->path);
}
$version++;
}
+29
View File
@@ -79,5 +79,34 @@ class repoTao extends repoModel
$pattern = "/^[a-zA-Z0-9_\-\.]+$/";
return preg_match($pattern, $repo->name);
}
/**
* Copy svn dir.
*
* @param int $repoID
* @param string $copyfromPath
* @param string $copyfromRev
* @param string $dirPath
* @access protected
* @return viod
*/
protected function copySvnDir(int $repoID, string $copyfromPath, string $copyfromRev, string $dirPath)
{
$copyFiles = $this->dao->select('t1.*')->from(TABLE_REPOFILES)->alias('t1')
->leftJoin(TABLE_REPOHISTORY)->alias('t2')->on('t1.revision = t2.id')
->where('t1.repo')->eq($repoID)
->andWhere('t2.revision+0')->le($copyfromRev)
->andWhere('t1.path')->like("{$copyfromPath}%")
->fetchAll();
foreach($copyFiles as $copyFile)
{
unset($copyFile->id);
$copyFile->path = substr_replace($copyFile->path, $dirPath, 0, strlen($copyfromPath));
$copyFile->parent = substr_replace($copyFile->parent, $dirPath, 0, strlen($copyfromPath));
if($copyFile->path == $dirPath) continue;
$this->dao->insert(TABLE_REPOFILES)->data($copyFile)->exec();
}
}
}