* Fix feedback#5175,5271

This commit is contained in:
zenggang
2024-03-12 02:45:01 +00:00
parent 6d6a7aec02
commit ef0f0559ef
4 changed files with 60 additions and 6 deletions
+5 -2
View File
@@ -603,12 +603,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);
@@ -639,6 +639,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;
}
}
+8 -1
View File
@@ -1156,7 +1156,14 @@ class repo extends control
$latestInDB = $this->repo->getLatestCommit($repoID, false);
$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;
}
$batchNum = $type == 'batch' ? $this->config->repo->batchNum : 0;
$logs = $this->scm->getCommits($revision, $batchNum, $branchID);
}
+18 -3
View File
@@ -398,7 +398,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 || $repo->scm == 'Subversion') && $repo->path != $data->path)
{
$this->repoTao->deleteInfoByID($repo->id);
return false;
@@ -894,12 +894,15 @@ class repoModel extends model
public function getLatestCommit(int $repoID, bool $checkCount = true): object|false
{
$repo = $this->fetchByID($repoID);
$orderBy = $repo->SCM == 'Subversion' ? 'svnRevision desc' : 't1.time desc';
$branchID = (string)$this->cookie->repoBranch;
$lastComment = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
$lastComment = $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 != 'Subversion' && $branchID)->andWhere('t2.branch')->eq($branchID)->fi()
->orderBy('t1.time desc')
->beginIF($repo->SCM == 'Subversion')->andWhere('t1.time')->ne('1970-01-01 08:00:00')->fi()
->orderBy($orderBy)
->fetch();
if(empty($lastComment)) return false;
if(!$checkCount) return $lastComment;
@@ -1061,6 +1064,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;
@@ -1074,6 +1082,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;
@@ -1122,6 +1132,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;
@@ -1143,6 +1156,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
@@ -307,4 +307,33 @@ class repoTao extends repoModel
return $matches;
}
/**
* Copy svn dir.
*
* @param int $repoID
* @param string $copyfromPath
* @param string $copyfromRev
* @param string $dirPath
* @access protected
* @return void
*/
protected function copySvnDir(int $repoID, string $copyfromPath, string $copyfromRev, string $dirPath): void
{
$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();
}
}
}