git support

This commit is contained in:
aaron
2019-12-13 14:32:24 +08:00
parent 28a2ead76a
commit 2b4fbf2355
11 changed files with 121 additions and 21 deletions
+20 -1
View File
@@ -352,6 +352,25 @@ class ci extends control
$this->send(array('result' => 'success'));
}
/**
* browse branches.
*
* @param int $repoID
* @access public
* @return void
*/
public function browseBranch($repoID = 0)
{
$repo = $this->ci->getRepoByID($repoID);
$branches = $this->ci->getBranches($repo);
$this->view->repo = $repo;
$this->view->branches = $branches;
$this->view->module = 'repo';
$this->display();
}
/**
* Show sync comment.
*
@@ -366,7 +385,7 @@ class ci extends control
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->showSyncComment;
$this->view->position[] = $this->lang->repo->showSyncComment;
$latestInDB = $this->ci->getLatestComment($repoID);
$latestInDB = $this->ci->getLatestComment($repoID, );
$this->view->version = $latestInDB ? (int)$latestInDB->commit : 1;
$this->view->repoID = $repoID;
$this->display();
+4
View File
@@ -0,0 +1,4 @@
$(function()
{
$('#' + module + 'Tab').addClass('btn-active-text');
})
+4
View File
@@ -0,0 +1,4 @@
$(function()
{
$('#' + module + 'Tab').addClass('btn-active-text');
})
+4
View File
@@ -0,0 +1,4 @@
$(function()
{
$('#' + module + 'Tab').addClass('btn-active-text');
})
+4
View File
@@ -0,0 +1,4 @@
$(function()
{
$('#' + module + 'Tab').addClass('btn-active-text');
});
+3
View File
@@ -2,6 +2,8 @@
$lang->ci->common = '持续集成';
$lang->ci->list = '列表';
$lang->ci->create = '添加';
$lang->ci->numb = '序号';
$lang->ci->name = '名称';
$lang->ci->subModules['credential'] = '凭证';
$lang->ci->subModules['jenkins'] = 'Jenkins';
@@ -75,6 +77,7 @@ $lang->repo->example->encoding = "填写版本库中文件的编码";
$lang->repo->svnCredentialLimt = "Subversion版本库的凭证必须为用户名密码类型";
$lang->repo->showSyncComment = '显示同步进度';
$lang->repo->watch = '监听';
$lang->repo->notice = new stdclass();
$lang->repo->notice->syncing = '正在同步中, 请稍等...';
+17 -16
View File
@@ -295,6 +295,20 @@ class ciModel extends model
return true;
}
/**
* Get git branches.
*
* @param object $repo
* @access public
* @return array
*/
public function getBranches($repo)
{
$this->scm = $this->app->loadClass('scm');
$this->scm->setEngine($repo);
return $this->scm->branch();
}
/**
* Check repo connection
*
@@ -397,18 +411,18 @@ class ciModel extends model
* @access public
* @return object
*/
public function getLatestComment($repoID)
public function getLatestComment($repoID, $branchID='')
{
$count = $this->dao->select('count(DISTINCT t1.id) as count')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.repo')->eq($repoID)
// ->beginIF($this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->beginIF($branchID)->andWhere('t2.branch')->eq($branchID)->fi()
->fetch('count');
$lastComment = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.repo')->eq($repoID)
// ->beginIF($this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->beginIF($branchID)->andWhere('t2.branch')->eq($branchID)->fi()
->orderBy('t1.time desc')
->limit(1)
->fetch();
@@ -424,19 +438,6 @@ class ciModel extends model
return $lastComment;
}
/**
* Set repo branch.
*
* @param string $branch
* @access public
* @return void
*/
// public function setRepoBranch($branch)
// {
// setcookie("repoBranch", $branch, 0, $this->config->webRoot);
// $_COOKIE['repoBranch'] = $branch;
// }
/**
* Save commit.
*
+58
View File
@@ -0,0 +1,58 @@
<?php
/**
* The view branch file of branch module of ZenTaoPMS.
*
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chenqi <chenqi@cnezsoft.com>
* @package ci
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include 'header.html.php'; ?>
<div id='mainContent' class='main-row'>
<div class='side-col' id='sidebar'>
<?php include 'menu.html.php'; ?>
</div>
<div class='main-col main-content'>
<form class='main-table' id='ajaxForm' method='post'>
<table id='branchList' class='table has-sort-head table-fixed'>
<thead>
<tr>
<th class='w-60px'><?php echo $lang->ci->numb; ?></th>
<th class='w-120px'><?php echo $lang->ci->name; ?></th>
<th class='w-60px'><?php echo $lang->repo->watch; ?></th>
<th class='c-actions-4'><?php echo $lang->actions; ?></th>
</tr>
</thead>
<tbody>
<?php $index = 0;
foreach ($branches as $id => $branch): ?>
<tr>
<td class='text'><?php echo ++$index; ?></td>
<td class='text' title='<?php echo $branch; ?>'><?php echo $id; ?></td>
<td>
<input type='checkbox' id='future' name='future' value='1' />
</td>
<td class='c-actions text-right'>
<?php
common::printIcon('ci', 'editRepo', "branchID=$id", '', 'list', 'edit');
if (common::hasPriv('ci', 'deleteRepo')) {
$deleteURL = $this->createLink('ci', 'deleteRepo', "branchID=$id&confirm=yes");
echo html::a("javascript:ajaxDelete(\"$deleteURL\", \"branchList\", confirmDelete)", '<i class="icon-trash"></i>', '', "title='{$lang->branch->delete}' class='btn'");
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($branchs): ?>
<div class='table-footer'><?php $pager->show('rignt', 'pagerjs'); ?></div>
<?php endif; ?>
</form>
</div>
</div>
<?php include '../../common/view/footer.html.php'; ?>
+1 -1
View File
@@ -39,7 +39,7 @@
<td class='text' title='<?php echo $repo->path; ?>'><?php echo $repo->path; ?></td>
<td class='c-actions text-right'>
<?php
common::printIcon('ci', 'viewRepo', "repoID=$id", '', 'list', 'file-text');
common::printIcon('ci', 'browseBranch', "repoID=$id", '', 'list', 'file-text');
common::printIcon('ci', 'editRepo', "repoID=$id", '', 'list', 'edit');
if (common::hasPriv('ci', 'deleteRepo')) {
$deleteURL = $this->createLink('ci', 'deleteRepo', "repoID=$id&confirm=yes");
+5 -2
View File
@@ -17,11 +17,14 @@
<div class='btn-group'>
<div class='btn-group' id='createActionMenu'>
<?php
if(strpos($this->methodName,'browse') > -1 && (true || common::hasPriv($module, 'create'))) {
if($this->methodName !== 'browsebranch' && strpos($this->methodName,'browse') > -1 && common::hasPriv($module, 'create')) {
echo html::a(inlink('create' . $module),
"<i class='icon-plus'></i> {$lang->ci->create}{$lang->ci->subModules[$module]}",
'', "class='btn btn-primary'");
}?>
} else if($this->methodName == 'browsebranch') {
echo html::backButton();
}
?>
</div>
</div>
</div>
+1 -1
View File
@@ -399,7 +399,7 @@ $lang->admin->subMenu->message->setting = array('link' => '设置|message|settin
$lang->admin->subMenu->sso = new stdclass();
$lang->admin->subMenu->sso->ranzhi = '然之协同|admin|sso';
$lang->admin->subMenu->sso->ci = array('link' => '持续集成|ci|index',
'alias' => 'browsecredential,createcredential,editcredential,browsejenkins,createjenkins,editjenkins');
'alias' => 'browsecredential,createcredential,editcredential,browsejenkins,createjenkins,editjenkins,browserepo,editrepo,browsebranch');
$lang->admin->subMenu->dev = new stdclass();
$lang->admin->subMenu->dev->api = array('link' => 'API|dev|api');