test and fix issues about svn

This commit is contained in:
aaronchen2k
2020-02-01 09:52:58 +08:00
parent 4637b81362
commit b713feabc5
6 changed files with 29 additions and 121 deletions
+4
View File
@@ -30,3 +30,7 @@ $config->repo->binary = '|pdf|';
$config->repo->editor = new stdclass();
$config->repo->editor->view = array('id' => 'commentText', 'tools' => 'simpleTools');
$config->repo->editor->diff = array('id' => 'commentText', 'tools' => 'simpleTools');
$config->repo->create->requiredFields = 'SCM,name,path,encoding,client';
$config->repo->edit->requiredFields = 'SCM,name,path,encoding,client';
$config->repo->svn->requiredFields = 'account,password';
+1 -1
View File
@@ -114,7 +114,7 @@ class repo extends control
$repoID = $this->session->repoID;
$this->repo->setMenu($this->repos, $repoID, false);
$repo = $this->repo->getByID($repoID);
$repo = $this->repo->getRepoByID($repoID);
if($_POST)
{
$noNeedSync = $this->repo->update($repoID);
+2 -1
View File
@@ -106,8 +106,8 @@ $lang->repo->logStyles['D'] = '删除';
$lang->repo->encodingList['utf_8'] = 'UTF-8';
$lang->repo->encodingList['gbk'] = 'GBK';
//$lang->repo->scmList['Subversion'] = 'Subversion';
$lang->repo->scmList['Git'] = 'Git';
$lang->repo->scmList['Subversion'] = 'Subversion';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = '正在同步中, 请稍等...';
@@ -119,6 +119,7 @@ $lang->repo->notice->commentContent = '输入回复内容';
$lang->repo->notice->deleteBug = '确认删除该Bug?';
$lang->repo->notice->deleteComment = '确认删除该回复?';
$lang->repo->notice->lastSyncTime = '最后更新于:';
$lang->repo->notice->passwordTips = '密码已加密存储,需修改请重新输入。';
$lang->repo->error = new stdclass();
$lang->repo->error->useless = '你的服务器禁用了exec,shell_exec方法,无法使用该功能';
+9 -97
View File
@@ -154,19 +154,6 @@ class repoModel extends model
return $repos;
}
/**
* Get a repo by id.
*
* @param int $id
* @access public
* @return object
*/
public function getByID($id)
{
$repo = $this->dao->select('*')->from(TABLE_REPO)->where('id')->eq($id)->fetch();
return $repo;
}
/**
* Create a repo.
*
@@ -175,19 +162,8 @@ class repoModel extends model
*/
public function create()
{
$data = fixer::input('post')->skipSpecial('path,client,account,password')->get();
if ($data->SCM === 'Subversion') {
$credentials = $this->loadModel('cicredentials')->getByID($data->credentials);
if ($credentials->type != 'account') {
dao::$errors['credentials'][] = $this->repo->svnCredentialsLimt;
return;
}
}
$this->checkConnection();
$data = fixer::input('post')->skipSpecial('path,client,account,password')->get();
$data->acl = empty($data->acl) ? '' : json_encode($data->acl);
if(empty($data->client)) $data->client = 'svn';
@@ -200,9 +176,10 @@ class repoModel extends model
if($data->prefix) $data->prefix = '/' . $data->prefix;
}
if($data->encrypt == 'base64') $data->password = base64_encode($data->password);
$data->password = base64_encode($data->password);
$this->dao->insert(TABLE_REPO)->data($data)
->batchCheck($this->config->repo->create->requiredFields, 'notempty')
->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty')
->autoCheck()
->exec();
return $this->dao->lastInsertID();
@@ -222,7 +199,7 @@ class repoModel extends model
$data->acl = empty($data->acl) ? '' : json_encode($data->acl);
if(empty($data->client)) $data->client = 'svn';
$repo = $this->getByID($id);
$repo = $this->getRepoByID($id);
$data->prefix = $repo->prefix;
if($data->SCM == 'Subversion' and $data->path != $repo->path)
{
@@ -238,11 +215,14 @@ class repoModel extends model
}
if($data->path != $repo->path) $data->synced = 0;
if($data->encrypt == 'base64') $data->password = base64_encode($data->password);
$data->password = base64_encode($data->password);
$this->dao->update(TABLE_REPO)->data($data)
->batchCheck($this->config->repo->create->requiredFields, 'notempty')
->batchCheck($this->config->repo->edit->requiredFields, 'notempty')
->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty')
->autoCheck()
->where('id')->eq($id)->exec();
if($repo->path != $data->path)
{
$this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($id)->exec();
@@ -285,7 +265,7 @@ class repoModel extends model
$repo = $this->dao->select('*')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch();
if(!$repo) return false;
if($repo->encrypt == 'base64') $repo->password = base64_decode($repo->password);
$repo->password = base64_decode($repo->password);
$repo->acl = json_decode($repo->acl);
return $repo;
}
@@ -551,74 +531,6 @@ class repoModel extends model
return substr($revision, 0, 10) . '<span title="' . sprintf($this->lang->repo->commitTitle, $commit) . '"> (' . $commit . ') </span>';
}
// /**
// * create
// *
// * @access public
// * @return int
// */
// public function create()
// {
// $this->checkConnection();
// $data = fixer::input('post')->skipSpecial('path,client,account,password')->get();
// $data->acl = empty($data->acl) ? '' : json_encode($data->acl);
// if(empty($data->client)) $data->client = 'svn';
//
// if($data->SCM == 'Subversion')
// {
// $scm = $this->app->loadClass('scm');
// $scm->setEngine($data);
// $info = $scm->info('');
// $data->prefix = empty($info->root) ? '' : trim(str_ireplace($info->root, '', str_replace('\\', '/', $data->path)), '/');
// if($data->prefix) $data->prefix = '/' . $data->prefix;
// }
//
// if($data->encrypt == 'base64') $data->password = base64_encode($data->password);
// $this->dao->insert(TABLE_REPO)->data($data)->exec();
// return $this->dao->lastInsertID();
// }
//
// /**
// * Save settings.
// *
// * @param int $repoID
// * @access public
// * @return bool
// */
// public function saveSettings($repoID)
// {
// $this->checkConnection();
// $data = fixer::input('post')->skipSpecial('path,client,account,password')->get();
// $data->acl = empty($data->acl) ? '' : json_encode($data->acl);
//
// if(empty($data->client)) $data->client = 'svn';
// $repo = $this->getRepoByID($repoID);
// $data->prefix = $repo->prefix;
// if($data->SCM == 'Subversion' and $data->path != $repo->path)
// {
// $scm = $this->app->loadClass('scm');
// $scm->setEngine($data);
// $info = $scm->info('');
// $data->prefix = empty($info->root) ? '' : trim(str_ireplace($info->root, '', str_replace('\\', '/', $data->path)), '/');
// if($data->prefix) $data->prefix = '/' . $data->prefix;
// }
// elseif($data->SCM != $repo->SCM and $data->SCM == 'Git')
// {
// $data->prefix = '';
// }
//
// if($data->path != $repo->path) $data->synced = 0;
// if($data->encrypt == 'base64') $data->password = base64_encode($data->password);
// $this->dao->update(TABLE_REPO)->data($data)->where('id')->eq($repoID)->exec();
// if($repo->path != $data->path)
// {
// $this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->exec();
// $this->dao->delete()->from(TABLE_REPOFILES)->where('repo')->eq($repoID)->exec();
// return false;
// }
// return true;
// }
/**
* Save commit.
*
+6 -10
View File
@@ -49,20 +49,16 @@
<td class='required'><?php echo html::input('client', '', "class='form-control'")?></td>
<td class='muted'><?php echo $lang->repo->example->client;?></td>
</tr>
<!--<tr>
<th><?php /*echo $lang->repo->account;*/?></th>
<td><?php /*echo html::input('account', '', "class='form-control'");*/?></td>
<tr>
<th><?php echo $lang->repo->account;?></th>
<td><?php echo html::input('account', '', "class='form-control'");?></td>
</tr>
<tr>
<th><?php /*echo $lang->repo->password;*/?></th>
<th><?php echo $lang->repo->password;?></th>
<td>
<div class='input-group'>
<?php /*echo html::password('password', '', "class='form-control'");*/?>
<span class='input-group-addon fix-border fix-padding'></span>
<?php /*echo html::select('encrypt', $lang->repo->encryptList, 'base64', "class='form-control'");*/?>
</div>
<?php echo html::password('password', '', "class='form-control'");?>
</td>
</tr>-->
</tr>
<tr>
<th><?php echo $lang->repo->acl;?></th>
+7 -12
View File
@@ -49,20 +49,15 @@
<td class='required'><?php echo html::input('client', $repo->client, "class='form-control'")?></td>
<td class='muted'><?php echo $lang->repo->example->client;?></td>
</tr>
<!--<tr>
<th><?php /*echo $lang->repo->account;*/?></th>
<td><?php /*echo html::input('account', '', "class='form-control'");*/?></td>
<tr>
<th><?php echo $lang->repo->account;?></th>
<td><?php echo html::input('account', $repo->account, "class='form-control'");?></td>
</tr>
<tr>
<th><?php /*echo $lang->repo->password;*/?></th>
<td>
<div class='input-group'>
<?php /*echo html::password('password', '', "class='form-control'");*/?>
<span class='input-group-addon fix-border fix-padding'></span>
<?php /*echo html::select('encrypt', $lang->repo->encryptList, 'base64', "class='form-control'");*/?>
</div>
</td>
</tr>-->
<th><?php echo $lang->repo->password;?></th>
<td><?php echo html::password('password', $repo->password, "class='form-control'");?></td>
<td></td>
</tr>
<tr>
<th><?php echo $lang->repo->acl;?></th>