* Fix bug#34264, gogs server failed to pull the code.

This commit is contained in:
chaideqing
2023-05-29 10:42:51 +08:00
parent d1977bf8ba
commit ebb396fb7e
11 changed files with 43 additions and 20 deletions
-1
View File
@@ -37,7 +37,6 @@ class gogs extends control
*/
public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
+1 -1
View File
@@ -343,7 +343,7 @@ class gogsModel extends model
$gogs = $this->getByID($gogsID);
$oauth = "{$gogs->token}@";
$project->tokenCloneUrl = preg_replace('/(http(s)?:\/\/)/', "\$1$oauth", $project->html_url);
$project->tokenCloneUrl = preg_replace('/(http(s)?:\/\/)/', '${1}' . $gogs->token . '@', $project->html_url);
}
return $project;
+13
View File
@@ -28,6 +28,19 @@ $config->repo->images = '|png|gif|jpg|ico|jpeg|bmp|';
$config->repo->binary = '|pdf|';
$config->repo->synced = '';
$config->repo->repoSyncLog = new stdclass();
$config->repo->repoSyncLog->one = 1;
$config->repo->repoSyncLog->done = 'done';
$config->repo->repoSyncLog->total = 'Total';
$config->repo->repoSyncLog->fatal = 'fatal';
$config->repo->repoSyncLog->error = 'error';
$config->repo->repoSyncLog->failed = 'failed';
$config->repo->repoSyncLog->finish = 'finish';
$config->repo->repoSyncLog->emptyRepo = 'empty repository';
$config->repo->repoSyncLog->finishCount = 'Counting objects: 100%';
$config->repo->repoSyncLog->logFilePrefix = '/log/clone.progress.';
$config->repo->repoSyncLog->finishCompress = 'Compressing objects: 100%';
$config->repo->editor = new stdclass();
$config->repo->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
$config->repo->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
+17 -17
View File
@@ -1433,50 +1433,50 @@ class repo extends control
* @param int $repoID
* @param string $type
* @access public
* @return void
* @return int|void
*/
public function ajaxSyncCommit($repoID = 0, $type = 'batch')
{
set_time_limit(0);
$repo = $this->repo->getRepoByID($repoID);
if(empty($repo)) return;
if($repo->synced) return print('finish');
if($repo->synced) return print($this->config->repo->repoSyncLog->finish);
if(in_array($repo->SCM, array('Gitea', 'Gogs')))
{
$logFile = realPath($this->app->getTmpRoot() . "/log/clone.progress." . strtolower($repo->SCM) . ".{$repo->name}.log");
$logFile = realPath($this->app->getTmpRoot() . $this->config->repo->repoSyncLog->logFilePrefix . strtolower($repo->SCM) . ".{$repo->name}.log");
if($logFile)
{
$content = file($logFile);
$lastLine = $content[count($content) - 1];
if(strpos($lastLine, 'done') === false)
foreach($content as $line)
{
if(strpos($lastLine, 'empty repository') !== false)
if(strpos($line, $this->config->repo->repoSyncLog->fatal) !== false or strpos($line, $this->config->repo->repoSyncLog->failed) !== false) return print($this->config->repo->repoSyncLog->error);
}
$lastLine = $content[count($content) - 1];
if(strpos($lastLine, $this->config->repo->repoSyncLog->done) === false)
{
if(strpos($lastLine, $this->config->repo->repoSyncLog->emptyRepo) !== false)
{
@unlink($logFile);
}
elseif(strpos($lastLine, 'Total') !== false)
elseif(strpos($lastLine, $this->config->repo->repoSyncLog->total) !== false)
{
$logContent = file_get_contents($logFile);
if(strpos($logContent, 'Counting objects: 100%') !== false and strpos($logContent, 'Compressing objects: 100%') !== false)
if(strpos($logContent, $this->config->repo->repoSyncLog->finishCount) !== false and strpos($logContent, $this->config->repo->repoSyncLog->finishCompress) !== false)
{
@unlink($logFile);
}
else
{
return print(1);
return print($this->config->repo->repoSyncLog->one);
}
}
else
{
return print(1);
return print($this->config->repo->repoSyncLog->one);
}
}
elseif(strpos($lastLine, 'fatal') !== false)
{
return print('finish');
}
else
{
@unlink($logFile);
@@ -1553,13 +1553,13 @@ class repo extends control
if(empty($branchID))
{
$this->repo->markSynced($repoID);
return print('finish');
return print($this->config->repo->repoSyncLog->finish);
}
}
}
$this->dao->update(TABLE_REPO)->set('commits=commits + ' . $commitCount)->where('id')->eq($repoID)->exec();
echo $type == 'batch' ? $commitCount : 'finish';
echo $type == 'batch' ? $commitCount : $this->config->repo->repoSyncLog->finish;
}
/**
+1
View File
@@ -177,6 +177,7 @@ $lang->repo->placeholder->gitlabHost = 'Input url of gitlab';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = 'Synchronizing. Please wait ...';
$lang->repo->notice->syncComplete = 'Synchronized. Now redirecting ...';
$lang->repo->notice->syncFailed = 'Synchronized failed.';
$lang->repo->notice->syncedCount = 'The number of records synchronized is ';
$lang->repo->notice->delete = 'Do you want to delete this repo?';
$lang->repo->notice->successDelete = 'Repository is removed.';
+1
View File
@@ -177,6 +177,7 @@ $lang->repo->placeholder->gitlabHost = 'Input url of gitlab';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = 'Synchronizing. Please wait ...';
$lang->repo->notice->syncComplete = 'Synchronized. Now redirecting ...';
$lang->repo->notice->syncFailed = 'Synchronized failed.';
$lang->repo->notice->syncedCount = 'The number of records synchronized is ';
$lang->repo->notice->delete = 'Do you want to delete this repo?';
$lang->repo->notice->successDelete = 'Repository is removed.';
+1
View File
@@ -177,6 +177,7 @@ $lang->repo->placeholder->gitlabHost = 'Input url of gitlab';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = 'Synchronisation en cours. Veuillez patienter ...';
$lang->repo->notice->syncComplete = 'Synchronisé. Vous allez être redirigé ...';
$lang->repo->notice->syncFailed = 'Synchronized failed.';
$lang->repo->notice->syncedCount = "Le nombre d'enregistrements synchronisés est ";
$lang->repo->notice->delete = 'Etes vous certain de vouloir supprimer ce référentiel ?';
$lang->repo->notice->successDelete = 'Le référentiel est supprimé.';
+2 -1
View File
@@ -168,7 +168,8 @@ $lang->repo->placeholder->gitlabHost = 'Input url of gitlab';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = 'Đang đồng bộ. Vui lòng đợi ...';
$lang->repo->notice->syncComplete = 'Synchronized. Now redirecting ...';
$lang->repo->notice->syncComplete = 'Đồng bộ hóa hoàn tất, nhảy ...';
$lang->repo->notice->syncFailed = 'Đồng bộ hóa không thành công.';
$lang->repo->notice->syncedCount = 'The number of records synchronized is ';
$lang->repo->notice->delete = 'Bạn có muốn xóa this repo?';
$lang->repo->notice->successDelete = 'Repository is removed.';
+1
View File
@@ -177,6 +177,7 @@ $lang->repo->placeholder->gitlabHost = '请填写GitLab访问地址';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = '正在同步中, 请稍等...';
$lang->repo->notice->syncComplete = '同步完成,正在跳转...';
$lang->repo->notice->syncFailed = '同步失败';
$lang->repo->notice->syncedCount = '已经同步记录条数';
$lang->repo->notice->delete = '是否要删除该代码库?';
$lang->repo->notice->successDelete = '已经成功删除代码库。';
+1
View File
@@ -154,6 +154,7 @@ $lang->repo->placeholder->gitlabHost = '請填寫GitLab訪問地址';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = '正在同步中, 請稍等...';
$lang->repo->notice->syncComplete = '同步完成,正在跳轉...';
$lang->repo->notice->syncFailed = '同步失敗.';
$lang->repo->notice->syncedCount = '已經同步記錄條數';
$lang->repo->notice->delete = '是否要刪除該版本庫?';
$lang->repo->notice->successDelete = '已經成功刪除版本庫。';
+5
View File
@@ -39,6 +39,11 @@ $(function(){
$('#caption').text('<?php echo $lang->repo->notice->syncComplete?>');
return self.location = '<?php echo $browseLink;?>';
}
if(data == 'error')
{
$('#mainContent .content p').text('<?php echo $lang->repo->notice->syncFailed?>');
return;
}
$('#commits').html(parseInt($('#commits').html()) + parseInt(data));
setTimeout(syncComments, 10);
});