Merge branch 'devops17'
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* The reporules entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yidong Wang <yidong@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class repoRulesEntry extends entry
|
||||
{
|
||||
/**
|
||||
* GET method.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$control = $this->loadController('repo', 'ajaxGetRules');
|
||||
$control->ajaxGetRules();
|
||||
|
||||
$data = $this->getData();
|
||||
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$this->send(200, $data->rules);
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,7 @@ $filter->user->edit = new stdclass();
|
||||
$filter->webhook->bind = new stdclass();
|
||||
$filter->user->ajaxgetmore = new stdclass();
|
||||
$filter->repo->ajaxsynccommit = new stdclass();
|
||||
$filter->repo->apigetrepobyurl = new stdclass();
|
||||
$filter->search->index = new stdclass();
|
||||
$filter->gitlab->webhook = new stdclass();
|
||||
$filter->gitlab->importissue = new stdclass();
|
||||
@@ -365,6 +366,8 @@ $filter->repo->default->get['repoPath'] = 'reg::base64';
|
||||
$filter->repo->default->get['path'] = 'reg::base64';
|
||||
$filter->repo->default->get['entry'] = 'reg::base64';
|
||||
|
||||
$filter->repo->apigetrepobyurl->get['url'] = 'reg::any';
|
||||
|
||||
$filter->repo->default->cookie['repoBranch'] = 'reg::any';
|
||||
$filter->repo->diff->cookie['arrange'] = 'reg::word';
|
||||
$filter->repo->diff->cookie['repoPairs'] = 'array';
|
||||
|
||||
+2
-1
@@ -118,7 +118,8 @@ $routes['/doclibs/:id'] = 'docs';
|
||||
$routes['/docs'] = 'docs';
|
||||
$routes['/docs/:id'] = 'doc';
|
||||
|
||||
$routes['/repos'] = 'repos';
|
||||
$routes['/repos'] = 'repos';
|
||||
$routes['/repos/rules'] = 'reporules';
|
||||
|
||||
$routes['/reports'] = 'reports';
|
||||
|
||||
|
||||
@@ -114,3 +114,14 @@ ALTER TABLE `zt_task` ADD `mr` mediumint(8) unsigned NOT NULL AFTER `repo`;
|
||||
ALTER TABLE `zt_bug` ADD `mr` mediumint(8) unsigned NOT NULL AFTER `repo`;
|
||||
|
||||
UPDATE `zt_grouppriv` SET `method`='addReview' where `module`='mr' and `method`='addBug';
|
||||
|
||||
ALTER TABLE `zt_repo` ADD `preMerge` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0' AFTER `extra`;
|
||||
ALTER TABLE `zt_repo` ADD `job` mediumint unsigned NOT NULL AFTER `preMerge`;
|
||||
ALTER TABLE `zt_mr` ADD `synced` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '1';
|
||||
ALTER TABLE `zt_mr` ADD `hasNoConflict` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `zt_mr` ADD `diffs` longtext COLLATE 'utf8_general_ci' NULL AFTER `synced`;
|
||||
ALTER TABLE `zt_mr` ADD `removeSourceBranch` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `compileStatus`;
|
||||
|
||||
ALTER TABLE zt_repo ADD fileServerUrl text COLLATE 'utf8_general_ci' NULL AFTER `job`;
|
||||
ALTER TABLE zt_repo ADD fileServerAccount varchar(40) NOT NULL default '' AFTER `fileServerUrl`;
|
||||
ALTER TABLE zt_repo ADD fileServerPassword varchar(100) NOT NULL default '' AFTER `fileServerAccount`;
|
||||
|
||||
@@ -847,6 +847,7 @@ CREATE TABLE IF NOT EXISTS `zt_mr` (
|
||||
`jobID` mediumint(8) unsigned NOT NULL,
|
||||
`compileID` mediumint(8) unsigned NOT NULL,
|
||||
`compileStatus` char(30) NOT NULL,
|
||||
`removeSourceBranch` enum('0','1') NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
-- DROP TABLE IF EXISTS `zt_mrapproval`;
|
||||
|
||||
@@ -593,6 +593,7 @@ class gitlab
|
||||
public function getCommittedDate($sha)
|
||||
{
|
||||
if(!scm::checkRevision($sha)) return null;
|
||||
if(!$sha or $sha == 'HEAD') return date('c');
|
||||
|
||||
global $dao;
|
||||
$time = $dao->select('time')->from(TABLE_REPOHISTORY)->where('revision')->eq($sha)->fetch('time');
|
||||
|
||||
@@ -125,6 +125,7 @@ $lang->action->objectTypes['gitlabuser'] = 'GitLab User';
|
||||
$lang->action->objectTypes['gitlabgroup'] = 'GitLab Group';
|
||||
$lang->action->objectTypes['gitlabbranch'] = 'GitLab Branch';
|
||||
$lang->action->objectTypes['gitlabbranchpriv'] = 'GitLab Protected Branches';
|
||||
$lang->action->objectTypes['gitlabtag'] = 'GitLab Tag';
|
||||
$lang->action->objectTypes['kanbanspace'] = 'Kanban Space';
|
||||
$lang->action->objectTypes['kanban'] = 'Kanban';
|
||||
$lang->action->objectTypes['kanbanregion'] = 'Kanban Region';
|
||||
|
||||
@@ -125,6 +125,7 @@ $lang->action->objectTypes['gitlabuser'] = 'GitLab用户';
|
||||
$lang->action->objectTypes['gitlabgroup'] = 'GitLab群组';
|
||||
$lang->action->objectTypes['gitlabbranch'] = 'GitLab分支';
|
||||
$lang->action->objectTypes['gitlabbranchpriv'] = 'GitLab保护分支';
|
||||
$lang->action->objectTypes['gitlabtag'] = 'GitLab标签';
|
||||
$lang->action->objectTypes['kanbanspace'] = '看板空间';
|
||||
$lang->action->objectTypes['kanban'] = '看板';
|
||||
$lang->action->objectTypes['kanbanregion'] = '看板区域';
|
||||
|
||||
@@ -199,6 +199,50 @@ class ciModel extends model
|
||||
{
|
||||
$this->dao->update(TABLE_COMPILE)->set('status')->eq($status)->where('id')->eq($build->id)->exec();
|
||||
$this->dao->update(TABLE_JOB)->set('lastExec')->eq(helper::now())->set('lastStatus')->eq($status)->where('id')->eq($build->job)->exec();
|
||||
|
||||
if($status == 'building') return;
|
||||
$relateMR = $this->dao->select('*')->from(TABLE_MR)->where('compileID')->eq($build->id)->fetch();
|
||||
if(isset($relateMR->synced) and $relateMR->synced == '0' and $status == 'success')
|
||||
{
|
||||
$newMR = new stdclass();
|
||||
$newMR->mergeStatus = 'can_be_merged';
|
||||
|
||||
/* Create a gitlab mr. */
|
||||
$MRObject = new stdclass();
|
||||
$MRObject->target_project_id = $relateMR->targetProject;
|
||||
$MRObject->source_branch = $relateMR->sourceBranch;
|
||||
$MRObject->target_branch = $relateMR->targetBranch;
|
||||
$MRObject->title = $relateMR->title;
|
||||
$MRObject->description = $relateMR->description;
|
||||
$MRObject->remove_source_branch = $relateMR->removeSourceBranch == '1' ? true : false;
|
||||
if($relateMR->assignee)
|
||||
{
|
||||
$gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($relateMR->gitlabID, $relateMR->assignee);
|
||||
if($gitlabAssignee) $MRObject->assignee_ids = $gitlabAssignee;
|
||||
}
|
||||
|
||||
$rawMR = $this->loadModel('mr')->apiCreateMR($relateMR->gitlabID, $relateMR->sourceProject, $MRObject);
|
||||
|
||||
if(!empty($rawMR->iid))
|
||||
{
|
||||
$newMR->mriid = $rawMR->iid;
|
||||
$newMR->status = $rawMR->state;
|
||||
$newMR->synced = '1';
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_MR)->data($newMR)
|
||||
->where('id')->eq($relateMR->id)
|
||||
->exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$newMR = new stdclass();
|
||||
$newMR->mergeStatus = 'cannot_merge_by_fail';
|
||||
|
||||
$this->dao->update(TABLE_MR)->data($newMR)
|
||||
->where('id')->eq($relateMR->id)
|
||||
->exec();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -132,7 +132,7 @@ class deptModel extends model
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getTreeMenu($rootDeptID = 0, $userFunc, $param = 0)
|
||||
public function getTreeMenu($rootDeptID = 0, $userFunc = '', $param = 0)
|
||||
{
|
||||
$deptMenu = array();
|
||||
$stmt = $this->dbh->query($this->buildMenuQuery($rootDeptID));
|
||||
@@ -376,7 +376,7 @@ class deptModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getUsers($browseType = 'inside', $deptID, $pager = null, $orderBy = 'id')
|
||||
public function getUsers($browseType = 'inside', $deptID = 0, $pager = null, $orderBy = 'id')
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_USER)
|
||||
->where('deleted')->eq(0)
|
||||
|
||||
@@ -430,8 +430,13 @@ class extension extends control
|
||||
|
||||
$tmpName = $_FILES['file']['tmp_name'];
|
||||
$fileName = $_FILES['file']['name'];
|
||||
$dest = $this->app->getTmpRoot() . "/extension/$fileName";
|
||||
move_uploaded_file($tmpName, $dest);
|
||||
$dest = $this->app->getTmpRoot() . "extension/$fileName";
|
||||
if(!move_uploaded_file($tmpName, $dest))
|
||||
{
|
||||
$downloadPath = $this->app->getTmpRoot() . 'extension/';
|
||||
$errorMessage = strip_tags(sprintf($this->lang->extension->errorDownloadPathNotWritable, $downloadPath, $downloadPath));
|
||||
die(js::alert($errorMessage));
|
||||
}
|
||||
|
||||
$extension = basename($fileName, '.zip');
|
||||
$return = $this->extension->extractPackage($extension);
|
||||
|
||||
@@ -11,6 +11,9 @@ $config->gitlab->createbranch->requiredFields = 'branch,ref';
|
||||
$config->gitlab->createbranchpriv = new stdclass;
|
||||
$config->gitlab->createbranchpriv->requiredFields = 'name';
|
||||
|
||||
$config->gitlab->createtag = new stdclass;
|
||||
$config->gitlab->createtag->requiredFields = 'tag_name,ref';
|
||||
|
||||
$config->gitlab->labelPattern = new stdclass;
|
||||
$config->gitlab->labelPattern->task = '/^zentao_task\/\d+$/';
|
||||
$config->gitlab->labelPattern->bug = '/^zentao_bug\/\d+$/';
|
||||
|
||||
+104
-2
@@ -858,7 +858,6 @@ class gitlab extends control
|
||||
$branchPriv->mergeAccessLevel = 40; // Initialize data, and the operation authority is the maintainers by default.
|
||||
$branchPriv->pushAccessLevel = 40; // Initialize data, and the operation authority is the maintainers by default.
|
||||
|
||||
$gitlab = $this->gitlab->getByID($gitlabID);
|
||||
$title = $this->lang->gitlab->createBranchPriv;
|
||||
|
||||
if($branch)
|
||||
@@ -881,7 +880,6 @@ class gitlab extends control
|
||||
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $title;
|
||||
$this->view->pageTitle = $title;
|
||||
$this->view->gitlab = $gitlab;
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->branch = $branch;
|
||||
$this->view->projectID = $projectID;
|
||||
@@ -930,6 +928,52 @@ class gitlab extends control
|
||||
die(js::alert($reponse->message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse gitlab tag.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $orderBy
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browseTag($gitlabID, $projectID, $orderBy = 'updated_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$this->session->set('gitlabTagList', $this->app->getURI(true));
|
||||
$keyword = fixer::input('post')->setDefault('keyword', '')->get('keyword');
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$tagList = array();
|
||||
$result = $this->gitlab->apiGetTags($gitlabID, $projectID, $orderBy, $keyword, $pager);
|
||||
foreach($result as $gitlabTag)
|
||||
{
|
||||
$tag = new stdClass();
|
||||
$tag->name = $gitlabTag->name;
|
||||
$tag->lastCommitter = $gitlabTag->commit->committer_name;
|
||||
$tag->updated = date('Y-m-d H:i:s', strtotime($gitlabTag->commit->committed_date));
|
||||
$tag->protected = $gitlabTag->protected;
|
||||
|
||||
$tagList[] = $tag;
|
||||
}
|
||||
|
||||
$this->view->gitlab = $this->gitlab->getByID($gitlabID);
|
||||
$this->view->pager = $pager;
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browseTag;
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->keyword = $keyword;
|
||||
$this->view->project = $this->gitlab->apiGetSingleProject($gitlabID, $projectID);
|
||||
$this->view->gitlabTagList = $tagList;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Import gitlab issue to zentaopms.
|
||||
*
|
||||
@@ -1281,4 +1325,62 @@ class gitlab extends control
|
||||
}
|
||||
$this->send($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gitlab tag.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createTag($gitlabID, $projectID)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->gitlab->createTag($gitlabID, $projectID);
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browseTag', "gitlabID=$gitlabID&projectID=$projectID")));
|
||||
}
|
||||
|
||||
$gitlabBranches = $this->gitlab->apiGetBranches($gitlabID, $projectID);
|
||||
$branches = array();
|
||||
foreach($gitlabBranches as $branch)
|
||||
{
|
||||
$branches[$branch->name] = $branch->name;
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->createTag;
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->branches = $branches;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a gitlab tag.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $tagName
|
||||
* @param string $confirm yes|no
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteTag($gitlabID, $projectID, $tagName = '', $confirm = 'no')
|
||||
{
|
||||
if($confirm != 'yes') die(js::confirm($this->lang->gitlab->tag->confirmDelete , inlink('deleteTag', "gitlabID=$gitlabID&projectID=$projectID&tagName=$tagName&confirm=yes")));
|
||||
|
||||
$reponse = $this->gitlab->apiDeleteTag($gitlabID, $projectID, $tagName);
|
||||
|
||||
/* If the status code beginning with 20 is returned or empty is returned, it is successful. */
|
||||
if(!$reponse or substr($reponse->message, 0, 2) == '20')
|
||||
{
|
||||
$this->loadModel('action')->create('gitlabtag', $projectID, 'deleted', '', $project->name);
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
|
||||
die(js::alert($reponse->message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.text-c-counts > span {margin-left: 5px;}
|
||||
#mainMenu .pull-left {margin-right: 15px;}
|
||||
.c-actions-1 {width: 60px;}
|
||||
@@ -0,0 +1,2 @@
|
||||
.table-form>tbody>tr>th {width: 110px;}
|
||||
.table-form {width: 50%;}
|
||||
@@ -0,0 +1,17 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#tagSearch').click(function()
|
||||
{
|
||||
triggerSearch();
|
||||
});
|
||||
$('#keyword').keypress(function(event)
|
||||
{
|
||||
if(event.which == 13) triggerSearch();
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
function triggerSearch()
|
||||
{
|
||||
$("#tagForm").submit();
|
||||
}
|
||||
@@ -31,6 +31,7 @@ $lang->gitlab->browseProject = "GitLab Project List";
|
||||
$lang->gitlab->browseUser = "User List";
|
||||
$lang->gitlab->browseGroup = "Group List";
|
||||
$lang->gitlab->browseBranch = "GitLab Branch List";
|
||||
$lang->gitlab->browseTag = "GitLab Tag List";
|
||||
$lang->gitlab->gitlabIssue = "GitLab Issue";
|
||||
$lang->gitlab->zentaoProduct = 'Zentao Product';
|
||||
$lang->gitlab->objectType = 'Type'; // task, bug, story
|
||||
@@ -51,6 +52,8 @@ $lang->gitlab->browseBranchPriv = 'Protect branch';
|
||||
$lang->gitlab->createBranchPriv = 'Cerate branch protected';
|
||||
$lang->gitlab->editBranchPriv = 'Edit branch protected';
|
||||
$lang->gitlab->deleteBranchPriv = 'Delete branch protected';
|
||||
$lang->gitlab->createTag = 'Create Tag';
|
||||
$lang->gitlab->deleteTag = 'Delete tag';
|
||||
|
||||
$lang->gitlab->id = 'ID';
|
||||
$lang->gitlab->name = "GitLab Name";
|
||||
@@ -202,3 +205,15 @@ $lang->gitlab->branch->branchCreationLevelList[30] = "Developers + Maintainers";
|
||||
$lang->gitlab->branch->branchCreationLevelList[0] = "No one";
|
||||
$lang->gitlab->branch->emptyPrivNameError = "Branch cannot be empty.";
|
||||
$lang->gitlab->branch->issetPrivNameError = "The protection branch already exists";
|
||||
|
||||
$lang->gitlab->tag = new stdclass();
|
||||
$lang->gitlab->tag->name = 'Tag name';
|
||||
$lang->gitlab->tag->ref = 'Create from';
|
||||
$lang->gitlab->tag->message = 'Message';
|
||||
$lang->gitlab->tag->lastCommitter = 'Last Committer';
|
||||
$lang->gitlab->tag->lastCommittedDate = 'Last Committed Date';
|
||||
$lang->gitlab->tag->placeholderSearch = "Enter branch tag";
|
||||
$lang->gitlab->tag->emptyNameError = "Name cannot be empty.";
|
||||
$lang->gitlab->tag->emptyRefError = "Create from cannot be empty.";
|
||||
$lang->gitlab->tag->issetNameError = "The tag already exists";
|
||||
$lang->gitlab->tag->confirmDelete = 'Do you want to delete this GitLab tag?';
|
||||
|
||||
@@ -31,6 +31,7 @@ $lang->gitlab->browseProject = "{$lang->gitlab->common}项目列表";
|
||||
$lang->gitlab->browseUser = "用户列表";
|
||||
$lang->gitlab->browseGroup = "群组列表";
|
||||
$lang->gitlab->browseBranch = "GitLab分支列表";
|
||||
$lang->gitlab->browseTag = "GitLab标签列表";
|
||||
$lang->gitlab->gitlabIssue = "{$lang->gitlab->common} issue";
|
||||
$lang->gitlab->zentaoProduct = '禅道产品';
|
||||
$lang->gitlab->objectType = '类型'; // task, bug, story
|
||||
@@ -51,6 +52,8 @@ $lang->gitlab->browseBranchPriv = '分支保护管理';
|
||||
$lang->gitlab->createBranchPriv = '创建分支保护';
|
||||
$lang->gitlab->editBranchPriv = '编辑分支保护';
|
||||
$lang->gitlab->deleteBranchPriv = '删除分支保护';
|
||||
$lang->gitlab->createTag = '创建标签';
|
||||
$lang->gitlab->deleteTag = '删除标签';
|
||||
|
||||
$lang->gitlab->id = 'ID';
|
||||
$lang->gitlab->name = "{$lang->gitlab->common}名称";
|
||||
@@ -202,3 +205,15 @@ $lang->gitlab->branch->branchCreationLevelList[30] = "开发者 + 维护者";
|
||||
$lang->gitlab->branch->branchCreationLevelList[0] = "禁止";
|
||||
$lang->gitlab->branch->emptyPrivNameError = "分支不能为空";
|
||||
$lang->gitlab->branch->issetPrivNameError = "已存在该保护分支";
|
||||
|
||||
$lang->gitlab->tag = new stdclass();
|
||||
$lang->gitlab->tag->name = '标签名';
|
||||
$lang->gitlab->tag->ref = '创建自';
|
||||
$lang->gitlab->tag->lastCommitter = '最后提交';
|
||||
$lang->gitlab->tag->lastCommittedDate = '最后修改时间';
|
||||
$lang->gitlab->tag->placeholderSearch = "请输入标签名称";
|
||||
$lang->gitlab->tag->message = '信息';
|
||||
$lang->gitlab->tag->emptyNameError = "标签名不能为空";
|
||||
$lang->gitlab->tag->emptyRefError = "创建自不能为空";
|
||||
$lang->gitlab->tag->issetNameError = "已存在该标签";
|
||||
$lang->gitlab->tag->confirmDelete = '确认删除该GitLab标签吗?';
|
||||
|
||||
+103
-7
@@ -635,7 +635,7 @@ class gitlabModel extends model
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @access public
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetProjects($gitlabID)
|
||||
{
|
||||
@@ -1462,15 +1462,63 @@ class gitlabModel extends model
|
||||
/**
|
||||
* Get project repository tags by api.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $orderBy
|
||||
* @param string $keyword
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiGetTags($gitlabID, $projectID)
|
||||
public function apiGetTags($gitlabID, $projectID, $orderBy = '', $keyword = '', $pager = null)
|
||||
{
|
||||
$url = sprintf($this->getApiRoot($gitlabID), "/projects/{$projectID}/repository/tags");
|
||||
return json_decode(commonModel::http($url));
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
|
||||
/* Parse order string. */
|
||||
if($orderBy)
|
||||
{
|
||||
list($order, $sort) = explode('_', $orderBy);
|
||||
$apiRoot .= "&order_by={$order}&sort={$sort}";
|
||||
}
|
||||
|
||||
if($keyword) $apiRoot .= "&search={$keyword}";
|
||||
|
||||
if(!$pager)
|
||||
{
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
else
|
||||
{
|
||||
$apiRoot .= "&per_page={$pager->recPerPage}&page={$pager->pageID}";
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags");
|
||||
$result = commonModel::httpWithHeader($url);
|
||||
|
||||
$header = $result['header'];
|
||||
$pager->setRecTotal($header['X-Total']);
|
||||
$pager->setPageTotal();
|
||||
if($pager->pageID > $pager->pageTotal) $pager->setPageID($pager->pageTotal);
|
||||
|
||||
return json_decode($result['body']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a gitab tag by api.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $tagName
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiDeleteTag($gitlabID, $projectID, $tagName = '')
|
||||
{
|
||||
if(!(int)$gitlabID or !(int)$projectID or empty($tagName)) return false;
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags/{$tagName}");
|
||||
return json_decode(commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2460,7 +2508,7 @@ class gitlabModel extends model
|
||||
if(is_array($accessLevels))
|
||||
{
|
||||
$levels = array();
|
||||
foreach($accessLevels as $level)
|
||||
foreach($accessLevels as $level)
|
||||
{
|
||||
if(is_array($level)) $level = (object)$level;
|
||||
$levels[] = isset($level->access_level) ? (int)$level->access_level : $maintainerAccess;
|
||||
@@ -2470,4 +2518,52 @@ class gitlabModel extends model
|
||||
}
|
||||
return $maintainerAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single branch by API.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $tag
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiGetSingleTag($gitlabID, $projectID, $tag)
|
||||
{
|
||||
if(empty($gitlabID)) return false;
|
||||
$url = sprintf($this->getApiRoot($gitlabID), "/projects/$projectID/repository/tags/$tag");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create gitlab tag.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function createTag($gitlabID, $projectID)
|
||||
{
|
||||
if(empty($gitlabID)) return false;
|
||||
|
||||
$tag = fixer::input('post')->get();
|
||||
if(empty($tag->tag_name)) dao::$errors['tag_name'][] = $this->lang->gitlab->tag->emptyNameError;
|
||||
if(empty($tag->ref)) dao::$errors['ref'][] = $this->lang->gitlab->tag->emptyRefError;
|
||||
|
||||
$singleBranch = $this->apiGetSingleTag($gitlabID, $projectID, $tag->tag_name);
|
||||
if(!empty($singleBranch->name)) dao::$errors['tag_name'][] = $this->lang->gitlab->tag->issetNameError;
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$url = sprintf($this->getApiRoot($gitlabID), "/projects/" . $projectID . '/repository/tags');
|
||||
$response = json_decode(commonModel::http($url, $tag));
|
||||
|
||||
if(!empty($response->name))
|
||||
{
|
||||
$this->loadModel('action')->create('gitlabtag', 0, 'created', '', $response->name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->apiErrorHandling($response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->project->name);?></th>
|
||||
<th class='text-left'></th>
|
||||
<th class='text-left'><?php echo $lang->gitlab->lastUpdate;?></th>
|
||||
<th class='c-actions-4'><?php echo $lang->actions;?></th>
|
||||
<th class='c-actions-5'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -67,9 +67,9 @@
|
||||
<td class='text' title='<?php echo substr($gitlabProject->last_activity_at, 0, 10);?>'><?php echo substr($gitlabProject->last_activity_at, 0, 10);?></td>
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
|
||||
common::printLink('gitlab', 'browseBranch', "gitlabID=$gitlabID&projectID=$gitlabProject->id", "<i class='icon icon-treemap'></i> ", '', "title='{$lang->gitlab->browseBranch}' class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'browseBranchPriv', "gitlabID=$gitlabID&projectID=$gitlabProject->id", "<i class='icon icon-branch-lock'></i> ", '', "title='{$lang->gitlab->branch->accessLevel}' class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'browseTag', "gitlabID=$gitlabID&projectID=$gitlabProject->id", "<i class='icon icon-tag'></i> ", '', "title='{$lang->gitlab->browseTag}' class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'editProject', "gitlabID=$gitlabID&projectID=$gitlabProject->id", "<i class='icon icon-edit'></i> ", '', "title='{$lang->gitlab->project->edit}' class='btn btn-primary'");
|
||||
if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'deleteProject', "gitlabID=$gitlabID&projectID=$gitlabProject->id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->gitlab->deleteProject}' class='btn'");
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse view file of gitlab module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Gang Zeng <zenggang@easycorp.ltd>
|
||||
* @package gitlab
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('vars', "keyword=%s&orderBy=id_desc&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID=1")?>
|
||||
<?php js::set('gitlabID', $gitlabID)?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class='pull-left'>
|
||||
<?php echo html::linkButton('<i class="icon icon-back icon-sm"></i> ' . $lang->goback, $this->createLink('gitlab', 'browseProject', "gitlabID=$gitlabID"), 'self', '','btn btn-secondary');?>
|
||||
</div>
|
||||
<div id="sidebarHeader">
|
||||
<div class="title" title="<?php echo $project->name_with_namespace; ?>"><?php echo $project->name_with_namespace; ?></div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-left">
|
||||
<div>
|
||||
<form id='tagForm' method='post'>
|
||||
<?php echo html::input('keyword', $keyword, "class='form-control' placeholder='{$lang->gitlab->tag->placeholderSearch}' style='display: inline-block;width:auto;margin:0 10px'");?>
|
||||
<a id="tagSearch" class="btn btn-primary"><?php echo $lang->gitlab->search?></a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::hasPriv('gitlab', 'createTag')) common::printLink('gitlab', 'createTag', "gitlabID=$gitlabID&projectID=$projectID", "<i class='icon icon-plus'></i> " . $lang->gitlab->createTag, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($gitlabTagList)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->noData;?></span>
|
||||
<?php if(empty($keyword) and common::hasPriv('gitlab', 'createTag')):?>
|
||||
<?php echo html::a($this->createLink('gitlab', 'createTag', "gitlabID=$gitlabID&projectID=$projectID"), "<i class='icon icon-plus'></i> " . $lang->gitlab->createTag, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='gitlabTagList' class='table has-sort-head table-fixed'>
|
||||
<?php $vars = "gitlabID={$gitlabID}&projectID={$projectID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->tag->name);?></th>
|
||||
<th class='text-left'><?php echo $lang->gitlab->tag->lastCommitter;?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('updated', $orderBy, $vars, $lang->gitlab->tag->lastCommittedDate);?></th>
|
||||
<th class='c-actions-1'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($gitlabTagList as $id => $gitlabTag): ?>
|
||||
<tr class='text'>
|
||||
<td class='text-c-name' title='<?php echo $gitlabTag->name;?>'><?php echo $gitlabTag->name;?></td>
|
||||
<td class='text'><?php echo $gitlabTag->lastCommitter;?></td>
|
||||
<td class='text'><?php echo $gitlabTag->updated?></td>
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
$isDisabled = $gitlabTag->protected ? 'disabled' : '';
|
||||
common::printLink('gitlab', 'deleteTag', "gitlabID=$gitlabID&projectID={$projectID}&tag_name={$gitlabTag->name}", "<i class='icon icon-trash'></i> ", '', "title='{$lang->gitlab->deleteTag}' class='btn btn-primary' target='hiddenwin' $isDisabled");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($gitlabTagList):?>
|
||||
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -21,7 +21,7 @@
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->branch->name;?></th>
|
||||
<td><?php echo html::input('branch', '', "class='form-control' placeholder='{$lang->gitlab->branch->name}'");?></td>
|
||||
<td><?php echo html::input('branch', '', "class='form-control'");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->branch->name;?></th>
|
||||
<td><?php echo html::select('name', $branches, $branchPriv->name, "class='form-control chosen' data-placeholder='{$lang->gitlab->branch->placeholderSelect}' " . ($branch ? 'disabled' : ''));?></td>
|
||||
<td><?php echo html::select('name', $branches, $branchPriv->name, "class='form-control chosen' " . ($branch ? 'disabled' : ''));?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->branch->mergeAllowed;?></th>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* The create view file of protext tag of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
|
||||
* @package gitlab
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-col main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->gitlab->createTag;?></h2>
|
||||
</div>
|
||||
<form id='tagForm' method='post' class='form-ajax' enctype="multipart/form-data">
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->tag->name;?></th>
|
||||
<td><?php echo html::input('tag_name', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->tag->ref;?></th>
|
||||
<td><?php echo html::select('ref', $branches, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->tag->message;?></th>
|
||||
<td><?php echo html::textarea('message', '', "rows='10' class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php if(!isonlybody()) echo html::a(inlink('browseTag', "gitlabID=$gitlabID&projectID=$projectID"), $lang->goback, '', 'class="btn btn-wide"');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -1122,20 +1122,21 @@ $lang->resource->automation->browse = 'browse';
|
||||
|
||||
$lang->automation->methodOrder[0] = 'browse';
|
||||
|
||||
$lang->resource->repo = new stdclass();
|
||||
$lang->resource->repo->browse = 'browseAction';
|
||||
$lang->resource->repo->view = 'view';
|
||||
$lang->resource->repo->log = 'log';
|
||||
$lang->resource->repo->revision = 'revisionAction';
|
||||
$lang->resource->repo->blame = 'blameAction';
|
||||
$lang->resource->repo->create = 'createAction';
|
||||
$lang->resource->repo->edit = 'editAction';
|
||||
$lang->resource->repo->delete = 'delete';
|
||||
$lang->resource->repo->showSyncCommit = 'showSyncCommit';
|
||||
$lang->resource->repo->diff = 'diffAction';
|
||||
$lang->resource->repo->download = 'downloadAction';
|
||||
$lang->resource->repo->maintain = 'maintain';
|
||||
$lang->resource->repo->setRules = 'setRules';
|
||||
$lang->resource->repo = new stdclass();
|
||||
$lang->resource->repo->browse = 'browseAction';
|
||||
$lang->resource->repo->view = 'view';
|
||||
$lang->resource->repo->log = 'log';
|
||||
$lang->resource->repo->revision = 'revisionAction';
|
||||
$lang->resource->repo->blame = 'blameAction';
|
||||
$lang->resource->repo->create = 'createAction';
|
||||
$lang->resource->repo->edit = 'editAction';
|
||||
$lang->resource->repo->delete = 'delete';
|
||||
$lang->resource->repo->showSyncCommit = 'showSyncCommit';
|
||||
$lang->resource->repo->diff = 'diffAction';
|
||||
$lang->resource->repo->download = 'downloadAction';
|
||||
$lang->resource->repo->maintain = 'maintain';
|
||||
$lang->resource->repo->setRules = 'setRules';
|
||||
$lang->resource->repo->apiGetRepoByUrl = 'apiGetRepoByUrl';
|
||||
|
||||
$lang->repo->methodOrder[5] = 'create';
|
||||
$lang->repo->methodOrder[10] = 'edit';
|
||||
@@ -1150,6 +1151,7 @@ $lang->repo->methodOrder[50] = 'revision';
|
||||
$lang->repo->methodOrder[55] = 'blame';
|
||||
$lang->repo->methodOrder[60] = 'download';
|
||||
$lang->repo->methodOrder[65] = 'setRules';
|
||||
$lang->repo->methodOrder[70] = 'apiGetRepoByUrl';
|
||||
|
||||
$lang->resource->ci = new stdclass();
|
||||
$lang->resource->ci->commitResult = 'commitResult';
|
||||
@@ -1333,6 +1335,9 @@ $lang->resource->gitlab->browseBranchPriv = 'browseBranchPriv';
|
||||
$lang->resource->gitlab->createBranchPriv = 'createBranchPriv';
|
||||
$lang->resource->gitlab->editBranchPriv = 'editBranchPriv';
|
||||
$lang->resource->gitlab->deleteBranchPriv = 'deleteBranchPriv';
|
||||
$lang->resource->gitlab->browseTag = 'browseTag';
|
||||
$lang->resource->gitlab->createTag = 'createTag';
|
||||
$lang->resource->gitlab->deleteTag = 'deleteTag';
|
||||
|
||||
$lang->gitlab->methodOrder[5] = 'browse';
|
||||
$lang->gitlab->methodOrder[10] = 'create';
|
||||
@@ -1359,10 +1364,12 @@ $lang->gitlab->methodOrder[115] = 'browseBranch';
|
||||
$lang->gitlab->methodOrder[120] = 'webhook';
|
||||
$lang->gitlab->methodOrder[125] = 'createWebhook';
|
||||
$lang->gitlab->methodOrder[130] = 'manageProjectMembers';
|
||||
$lang->gitlab->methodOrder[135] = 'browseTag';
|
||||
|
||||
/* merge request. */
|
||||
$lang->resource->mr = new stdclass();
|
||||
$lang->resource->mr->create = 'create';
|
||||
$lang->resource->mr->apiCreate = 'apiCreate';
|
||||
$lang->resource->mr->browse = 'browse';
|
||||
$lang->resource->mr->edit = 'edit';
|
||||
$lang->resource->mr->delete = 'delete';
|
||||
|
||||
@@ -66,6 +66,24 @@ class jobModel extends model
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get job pairs by RepoID.
|
||||
*
|
||||
* @param int $repoID
|
||||
* @param string $engine gitlab|jenkins
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPairs($repoID, $engine = '')
|
||||
{
|
||||
return $this->dao->select('id, name')->from(TABLE_JOB)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('repo')->eq($repoID)
|
||||
->beginIF($engine)->andWhere('engine')->eq($engine)->fi()
|
||||
->orderBy('id_desc')
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list by triggerType field.
|
||||
*
|
||||
|
||||
@@ -12,6 +12,9 @@ $config->mr->edit->requiredFields = 'gitlabID,sourceProject,sourceBranch,targetP
|
||||
$config->mr->editor = new stdclass();
|
||||
$config->mr->editor->diff = array('id' => 'commentText', 'tools' => 'simpleTools');
|
||||
|
||||
$config->mr->apicreate = new stdclass();
|
||||
$config->mr->apicreate->requiredFields = 'repoID,sourceBranch,targetBranch,mergeStatus,jobID';
|
||||
|
||||
$config->mr->maps = new stdclass;
|
||||
$config->mr->maps->sync = array();
|
||||
$config->mr->maps->sync['title'] = 'title|field|';
|
||||
|
||||
+33
-4
@@ -84,6 +84,30 @@ class mr extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create MR function by api.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function apiCreate()
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->mr->apiCreate();
|
||||
|
||||
$response['result'] = 'success';
|
||||
$response['message'] = '';
|
||||
if(dao::isError())
|
||||
{
|
||||
$response['result'] = 'fail';
|
||||
$response['message'] = dao::getError();
|
||||
}
|
||||
|
||||
return $this->send($response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit MR function.
|
||||
*
|
||||
@@ -183,7 +207,7 @@ class mr extends control
|
||||
$MR = $this->mr->getByID($id);
|
||||
if(!$MR) die(js::error($this->lang->notFound) . js::locate($this->createLink('mr', 'browse')));
|
||||
if(isset($MR->gitlabID)) $rawMR = $this->mr->apiGetSingleMR($MR->gitlabID, $MR->targetProject, $MR->mriid);
|
||||
if(!isset($rawMR->id) or (isset($rawMR->message) and $rawMR->message == '404 Not found') or empty($rawMR)) return $this->display();
|
||||
if($MR->synced and (!isset($rawMR->id) or (isset($rawMR->message) and $rawMR->message == '404 Not found') or empty($rawMR))) return $this->display();
|
||||
|
||||
$MR = $this->mr->apiSyncMR($MR); /* Sync MR from GitLab to ZentaoPMS. */
|
||||
$this->loadModel('gitlab');
|
||||
@@ -199,7 +223,7 @@ class mr extends control
|
||||
|
||||
/* Those variables are used to render $lang->mr->commandDocument. */
|
||||
$this->view->httpRepoURL = $sourceProject->http_url_to_repo;
|
||||
$this->view->branchPath = $sourceProject->path_with_namespace . '-' . $rawMR->source_branch;
|
||||
$this->view->branchPath = $sourceProject->path_with_namespace . '-' . $MR->sourceBranch;
|
||||
|
||||
/* Get mr linked list. */
|
||||
$this->app->loadLang('productplan');
|
||||
@@ -310,11 +334,16 @@ class mr extends control
|
||||
$encoding = strtolower(str_replace('_', '-', $encoding)); /* Revert $config->requestFix in $encoding. */
|
||||
|
||||
$MR = $this->mr->getByID($MRID);
|
||||
if(isset($MR->gitlabID)) $rawMR = $this->mr->apiGetSingleMR($MR->gitlabID, $MR->targetProject, $MR->mriid);
|
||||
$this->view->title = $this->lang->mr->viewDiff;
|
||||
$this->view->MR = $MR;
|
||||
|
||||
$rawMR = null;
|
||||
if($MR->synced)
|
||||
{
|
||||
$rawMR = $this->mr->apiGetSingleMR($MR->gitlabID, $MR->targetProject, $MR->mriid);
|
||||
if(!isset($rawMR->id) or (isset($rawMR->message) and $rawMR->message == '404 Not found') or empty($rawMR)) return $this->display();
|
||||
}
|
||||
$this->view->rawMR = $rawMR;
|
||||
if(!isset($rawMR->id) or (isset($rawMR->message) and $rawMR->message == '404 Not found') or empty($rawMR)) return $this->display();
|
||||
|
||||
$diffs = $this->mr->getDiffs($MR, $encoding);
|
||||
$arrange = $this->cookie->arrange ? $this->cookie->arrange : 'inline';
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#mrForm table tbody th {width: 145px;}
|
||||
@@ -0,0 +1 @@
|
||||
#mrForm table tbody th {width: 225px;}
|
||||
@@ -0,0 +1 @@
|
||||
#mrForm table tbody th {width: 145px;}
|
||||
@@ -0,0 +1 @@
|
||||
#mrForm table tbody th {width: 225px;}
|
||||
@@ -3,6 +3,7 @@ $lang->mr = new stdclass;
|
||||
$lang->mr->common = "Merge Request";
|
||||
$lang->mr->overview = "Survey";
|
||||
$lang->mr->create = "Create";
|
||||
$lang->mr->apiCreate = "Interface: Create";
|
||||
$lang->mr->browse = "Browse";
|
||||
$lang->mr->list = "List";
|
||||
$lang->mr->edit = "Edit";
|
||||
@@ -56,8 +57,9 @@ $lang->mr->approvalResultList = array();
|
||||
$lang->mr->approvalResultList['approve'] = 'Approve';
|
||||
$lang->mr->approvalResultList['reject'] = 'Reject';
|
||||
|
||||
$lang->mr->needApproved = 'This MR should be approved before merge';
|
||||
$lang->mr->needCI = 'This MR should be passed CI before merge';
|
||||
$lang->mr->needApproved = 'This MR should be approved before merge';
|
||||
$lang->mr->needCI = 'Merge only after passing CI';
|
||||
$lang->mr->removeSourceBranch = 'Delete source branch after merge';
|
||||
|
||||
$lang->mr->repeatedOperation = 'Do not repeat operations';
|
||||
|
||||
@@ -78,9 +80,10 @@ $lang->mr->statusList['merged'] = 'merged';
|
||||
$lang->mr->statusList['closed'] = 'closed';
|
||||
|
||||
$lang->mr->mergeStatusList = array();
|
||||
$lang->mr->mergeStatusList['checking'] = 'checking';
|
||||
$lang->mr->mergeStatusList['can_be_merged'] = 'can be merged';
|
||||
$lang->mr->mergeStatusList['cannot_be_merged'] = 'cannot be merged';
|
||||
$lang->mr->mergeStatusList['checking'] = 'checking';
|
||||
$lang->mr->mergeStatusList['can_be_merged'] = 'can be merged';
|
||||
$lang->mr->mergeStatusList['cannot_be_merged'] = 'cannot be merged';
|
||||
$lang->mr->mergeStatusList['cannot_merge_by_fail'] = 'Cannot be merged, check failed';
|
||||
|
||||
$lang->mr->description = 'Description';
|
||||
$lang->mr->confirmDelete = 'Are you sure to delete this merge request?';
|
||||
|
||||
@@ -3,6 +3,7 @@ $lang->mr = new stdclass;
|
||||
$lang->mr->common = "合并请求";
|
||||
$lang->mr->overview = "概况";
|
||||
$lang->mr->create = "创建{$lang->mr->common}";
|
||||
$lang->mr->apiCreate = "接口:创建{$lang->mr->common}";
|
||||
$lang->mr->browse = "浏览{$lang->mr->common}";
|
||||
$lang->mr->list = $lang->mr->browse;
|
||||
$lang->mr->edit = "编辑{$lang->mr->common}";
|
||||
@@ -56,8 +57,9 @@ $lang->mr->approvalResultList = array();
|
||||
$lang->mr->approvalResultList['approve'] = '通过';
|
||||
$lang->mr->approvalResultList['reject'] = '拒绝';
|
||||
|
||||
$lang->mr->needApproved = '需要通过评审才能合并';
|
||||
$lang->mr->needCI = '需要通过构建才能合并';
|
||||
$lang->mr->needApproved = '需要通过评审才能合并';
|
||||
$lang->mr->needCI = '需要通过构建才能合并';
|
||||
$lang->mr->removeSourceBranch = '合并后删除源分支';
|
||||
|
||||
$lang->mr->repeatedOperation = '请勿重复操作';
|
||||
|
||||
@@ -78,9 +80,10 @@ $lang->mr->statusList['merged'] = '已合并';
|
||||
$lang->mr->statusList['closed'] = '已关闭';
|
||||
|
||||
$lang->mr->mergeStatusList = array();
|
||||
$lang->mr->mergeStatusList['checking'] = '检查中';
|
||||
$lang->mr->mergeStatusList['can_be_merged'] = '可合并';
|
||||
$lang->mr->mergeStatusList['cannot_be_merged'] = '不可自动合并';
|
||||
$lang->mr->mergeStatusList['checking'] = '检查中';
|
||||
$lang->mr->mergeStatusList['can_be_merged'] = '可合并';
|
||||
$lang->mr->mergeStatusList['cannot_be_merged'] = '不可自动合并';
|
||||
$lang->mr->mergeStatusList['cannot_merge_by_fail'] = '不可合并,检查未通过';
|
||||
|
||||
$lang->mr->description = '描述';
|
||||
$lang->mr->confirmDelete = '确认删除该合并请求吗?';
|
||||
|
||||
+95
-11
@@ -87,6 +87,7 @@ class mrModel extends model
|
||||
$MR = fixer::input('post')
|
||||
->setDefault('jobID', 0)
|
||||
->setDefault('repoID', 0)
|
||||
->setDefault('removeSourceBranch','0')
|
||||
->setDefault('needCI', 0)
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
@@ -114,11 +115,12 @@ class mrModel extends model
|
||||
$MRID = $this->dao->lastInsertId();
|
||||
|
||||
$MRObject = new stdclass;
|
||||
$MRObject->target_project_id = $MR->targetProject;
|
||||
$MRObject->source_branch = $MR->sourceBranch;
|
||||
$MRObject->target_branch = $MR->targetBranch;
|
||||
$MRObject->title = $MR->title;
|
||||
$MRObject->description = $MR->description;
|
||||
$MRObject->target_project_id = $MR->targetProject;
|
||||
$MRObject->source_branch = $MR->sourceBranch;
|
||||
$MRObject->target_branch = $MR->targetBranch;
|
||||
$MRObject->title = $MR->title;
|
||||
$MRObject->description = $MR->description;
|
||||
$MRObject->remove_source_branch = $MR->removeSourceBranch == '1' ? true : false;
|
||||
if($MR->assignee)
|
||||
{
|
||||
$gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($this->post->gitlabID, $MR->assignee);
|
||||
@@ -176,6 +178,77 @@ class mrModel extends model
|
||||
return array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => helper::createLink('mr', 'browse'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create MR function by api.
|
||||
*
|
||||
* @access public
|
||||
* @return int|bool|object
|
||||
*/
|
||||
public function apiCreate()
|
||||
{
|
||||
$postData = fixer::input('post')->get();
|
||||
$postData = (object)$postData->data;
|
||||
|
||||
$repo = $this->loadModel('repo')->getRepoByUrl($postData->RepoUrl);
|
||||
if(empty($repo['data']))
|
||||
{
|
||||
dao::$errors[] = $repo['message'];
|
||||
return false;
|
||||
}
|
||||
$repo = $repo['data'];
|
||||
|
||||
/* Process and insert mr data. */
|
||||
$MR = new stdClass();
|
||||
$MR->gitlabID = $repo->client;
|
||||
$MR->sourceProject = $repo->path;
|
||||
$MR->sourceBranch = $postData->RepoSrcBranch;
|
||||
$MR->targetProject = $repo->path;
|
||||
$MR->targetBranch = $postData->RepoDistBranch;
|
||||
$MR->diffs = $this->post->data['DiffMsg'];
|
||||
$MR->title = $this->lang->mr->common . ' ' . $postData->RepoSrcBranch . $this->lang->mr->to . $postData->RepoDistBranch ;
|
||||
$MR->repoID = $repo->id;
|
||||
$MR->jobID = isset($repo->job->id) ? $repo->job->id : 0;
|
||||
$MR->synced = '0';
|
||||
$MR->needCI = '1';
|
||||
$MR->approvalStatus = 'approved';
|
||||
$MR->hasNoConflict = $postData->MergeStatus ? '0' : '1';
|
||||
$MR->mergeStatus = $postData->MergeStatus ? 'can_be_merged' : 'cannot_be_merged';
|
||||
$MR->createdBy = $this->app->user->account;
|
||||
$MR->createdDate = date('Y-m-d H:i:s');
|
||||
|
||||
$this->dao->insert(TABLE_MR)->data($MR, $this->config->mr->create->skippedFields)
|
||||
->batchCheck($this->config->mr->apicreate->requiredFields, 'notempty')
|
||||
->autoCheck()
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Exec Job */
|
||||
if($MR->hasNoConflict == '0' && $MR->mergeStatus == 'can_be_merged' && $MR->jobID)
|
||||
{
|
||||
$MRID = $this->dao->lastInsertId();
|
||||
$pipeline = $this->loadModel('job')->exec($MR->jobID);
|
||||
$newMR = new stdClass();
|
||||
if(!empty($pipeline->queue))
|
||||
{
|
||||
$compile = $this->loadModel('compile')->getByQueue($pipeline->queue);
|
||||
$newMR->compileID = $compile->id;
|
||||
$newMR->compileStatus = $compile->status;
|
||||
}
|
||||
else
|
||||
{
|
||||
$newMR->compileStatus = $pipeline->status;
|
||||
}
|
||||
|
||||
/* Update MR in Zentao database. */
|
||||
$this->dao->update(TABLE_MR)->data($newMR)
|
||||
->where('id')->eq($MRID)
|
||||
->autoCheck()
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit MR function.
|
||||
*
|
||||
@@ -187,6 +260,7 @@ class mrModel extends model
|
||||
$MR = fixer::input('post')
|
||||
->setDefault('jobID', 0)
|
||||
->setDefault('repoID', 0)
|
||||
->setDefault('removeSourceBranch','0')
|
||||
->setDefault('needCI', 0)
|
||||
->setDefault('editedBy', $this->app->user->account)
|
||||
->setDefault('editedDate', helper::now())
|
||||
@@ -212,9 +286,10 @@ class mrModel extends model
|
||||
|
||||
/* Update MR in GitLab. */
|
||||
$newMR = new stdclass;
|
||||
$newMR->title = $MR->title;
|
||||
$newMR->description = $MR->description;
|
||||
$newMR->target_branch = $MR->targetBranch;
|
||||
$newMR->title = $MR->title;
|
||||
$newMR->description = $MR->description;
|
||||
$newMR->target_branch = $MR->targetBranch;
|
||||
$newMR->remove_source_branch = $MR->removeSourceBranch == '1' ? true : false;
|
||||
if($MR->assignee)
|
||||
{
|
||||
$gitlabAssignee = $this->gitlab->getUserIDByZentaoAccount($oldMR->gitlabID, $MR->assignee);
|
||||
@@ -563,8 +638,10 @@ class mrModel extends model
|
||||
*/
|
||||
public function getDiffs($MR, $encoding = '')
|
||||
{
|
||||
$diffVersions = $this->apiGetDiffVersions($MR->gitlabID, $MR->targetProject, $MR->mriid);
|
||||
$gitlab = $this->gitlab->getByID($MR->gitlabID);
|
||||
$diffVersions = array();
|
||||
if($MR->synced) $diffVersions = $this->apiGetDiffVersions($MR->gitlabID, $MR->targetProject, $MR->mriid);
|
||||
|
||||
$gitlab = $this->gitlab->getByID($MR->gitlabID);
|
||||
|
||||
$this->loadModel('repo');
|
||||
$repo = new stdclass;
|
||||
@@ -579,10 +656,11 @@ class mrModel extends model
|
||||
|
||||
$lines = array();
|
||||
$commitList = array();
|
||||
foreach ($diffVersions as $diffVersion)
|
||||
foreach($diffVersions as $diffVersion)
|
||||
{
|
||||
$singleDiff = $this->apiGetSingleDiffVersion($MR->gitlabID, $MR->targetProject, $MR->mriid, $diffVersion->id);
|
||||
if($singleDiff->state == 'empty') continue;
|
||||
|
||||
$commits = $singleDiff->commits;
|
||||
$diffs = $singleDiff->diffs;
|
||||
foreach($diffs as $index => $diff)
|
||||
@@ -602,6 +680,12 @@ class mrModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($MR->synced))
|
||||
{
|
||||
$diffs = preg_replace('/^\s*$\n?\r?/m', '', $MR->diffs);
|
||||
$lines = explode("\n", $diffs);
|
||||
}
|
||||
|
||||
$scm = $this->app->loadClass('scm');
|
||||
$scm->setEngine($repo);
|
||||
$diff = $scm->engine->parseDiff($lines);
|
||||
|
||||
@@ -55,6 +55,15 @@
|
||||
<th><?php echo $lang->devops->repo;?></th>
|
||||
<td colspan='1' class='required'><?php echo html::select('repoID', array(''), '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->removeSourceBranch;?></th>
|
||||
<td colspan='1'>
|
||||
<div class="checkbox-primary">
|
||||
<input type="checkbox" name="removeSourceBranch" value="1" id="removeSourceBranch">
|
||||
<label for="removeSourceBranch"></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->needCI;?></th>
|
||||
<td colspan='1'>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<?php include '../../common/view/form.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<?php /* If this mr is deleted in GitLab, then show this part to user. */?>
|
||||
<?php if(empty($rawMR) or !isset($rawMR->id)): ?>
|
||||
<?php if($MR->synced and (empty($rawMR) or !isset($rawMR->id))): ?>
|
||||
<div id='mainContent'>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
|
||||
@@ -69,6 +69,16 @@
|
||||
<th><?php echo $lang->devops->repo;?></th>
|
||||
<td colspan='1' class='required'><?php echo html::select('repoID', $repoList, $MR->repoID, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->removeSourceBranch;?></th>
|
||||
<td colspan='1'>
|
||||
<div class="checkbox-primary">
|
||||
<?php $checked = $MR->removeSourceBranch== '1' ? 'checked' : '' ?>
|
||||
<input type="checkbox" <?php echo $checked;?> name="removeSourceBranch" value="1" id="removeSourceBranch">
|
||||
<label for="removeSourceBranch"></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->needCI;?></th>
|
||||
<td colspan='1'>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php /* If this mr is deleted in GitLab, then show this part to user. */?>
|
||||
<?php elseif(empty($rawMR) or !isset($rawMR->id)): ?>
|
||||
<?php elseif($MR->synced and (empty($rawMR) or !isset($rawMR->id))): ?>
|
||||
<div id='mainContent'>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
@@ -28,7 +28,9 @@
|
||||
<div class="page-title">
|
||||
<span class="label label-id"><?php echo $MR->id ?></span>
|
||||
<span class="text" title='<?php echo $MR->title; ?>'><?php echo $MR->title; ?></span>
|
||||
<?php if($MR->synced):?>
|
||||
<span class="text" title='<?php echo $MR->title; ?>' style='color: blue'><?php echo html::a($rawMR->web_url, $lang->mr->viewInGitlab, "_blank", "class='btn btn-link btn-active-text' style='color: blue'"); ?></span>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -52,7 +54,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan='2'>
|
||||
<span><?php echo $lang->mr->from . html::a($sourceProjectURL, $sourceProjectName . ":" . $MR->sourceBranch, "_blank", "class='btn btn-link btn-active-text' style='color: blue'") . $lang->mr->to . html::a($targetProjectURL, $targetProjectName . ":" . $MR->targetBranch, "_blank", "class='btn btn-link btn-active-text' style='color: blue'"); ?></span>
|
||||
<?php $sourceDisabled = ($MR->status == 'merged' and $MR->removeSourceBranch == '1') ? 'disabled' : '';?>
|
||||
<span><?php echo $lang->mr->from . html::a($sourceProjectURL, $sourceProjectName . ":" . $MR->sourceBranch, "_blank", "class='btn btn-link btn-active-text' style='color: blue' $sourceDisabled") . $lang->mr->to . html::a($targetProjectURL, $targetProjectName . ":" . $MR->targetBranch, "_blank", "class='btn btn-link btn-active-text' style='color: blue'"); ?></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -63,7 +66,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->mergeStatus; ?></th>
|
||||
<?php if(empty($rawMR->changes_count)):?>
|
||||
<?php if($MR->synced and empty($rawMR->changes_count)):?>
|
||||
<td>
|
||||
<?php echo $lang->mr->cantMerge; ?>
|
||||
<code class=''><?php echo $lang->mr->noChanges;?></code>
|
||||
@@ -74,7 +77,8 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->MRHasConflicts; ?></th>
|
||||
<td><?php echo ($rawMR->has_conflicts ? $lang->mr->hasConflicts : $lang->mr->hasNoConflict);?></td>
|
||||
<?php $hasNoConflict = $MR->synced === '1' ? $rawMR->has_conflicts : (bool)$MR->hasNoConflict; ?>
|
||||
<td><?php echo ($hasNoConflict ? $lang->mr->hasConflicts : $lang->mr->hasNoConflict);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->mr->description;?></th>
|
||||
@@ -89,17 +93,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($rawMR->state == 'opened'): ?>
|
||||
<?php if($MR->synced and $rawMR->state == 'opened'): ?>
|
||||
<div class="cell"><?php echo sprintf($lang->mr->commandDocument, $httpRepoURL, $MR->sourceBranch, $branchPath, $MR->targetBranch, $branchPath, $MR->targetBranch); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class='main-actions'>
|
||||
<div class="btn-toolbar">
|
||||
<?php common::printBack(inlink('browse', '')); ?>
|
||||
<?php $acceptDisabled = ($MR->approvalStatus != 'approved' or ($MR->compileID !=0 and $MR->compileStatus != 'success')) ? ' disabled' : ''; ?>
|
||||
<?php if($rawMR->state == 'opened' and !$rawMR->has_conflicts) common::printIcon('mr', 'accept', "mr=$MR->id", $MR, 'button', 'flow', 'hiddenwin', 'mergeButton btn', false, $acceptDisabled, $lang->mr->acceptMR);?>
|
||||
<?php if($rawMR->state == 'opened'): ?>
|
||||
<?php if($rawMR->has_conflicts or ($MR->compileID !=0 and $MR->compileStatus != 'success') or $MR->approvalStatus == 'approved'):?>
|
||||
<?php $acceptDisabled = ($MR->approvalStatus != 'approved' or ($MR->compileID != 0 and $MR->compileStatus != 'success')) ? ' disabled' : ''; ?>
|
||||
<?php if($MR->synced and $rawMR->state == 'opened' and !$rawMR->has_conflicts) common::printIcon('mr', 'accept', "mr=$MR->id", $MR, 'button', 'flow', 'hiddenwin', 'mergeButton btn', false, $acceptDisabled, $lang->mr->acceptMR);?>
|
||||
<?php if($MR->synced and $rawMR->state == 'opened'): ?>
|
||||
<?php if($rawMR->has_conflicts or ($MR->compileID != 0 and $MR->compileStatus != 'success') or $MR->approvalStatus == 'approved'):?>
|
||||
<?php common::printIcon('mr', 'approval', "mr=$MR->id&action=approve", $MR, 'button', 'ok', 'hiddenwin', 'mergeButton', true, 'disabled', $lang->mr->approve);?>
|
||||
<?php else:?>
|
||||
<?php common::printIcon('mr', 'approval', "mr=$MR->id&action=approve", $MR, 'button', 'ok', 'hiddenwin', 'mergeButton btn iframe showinonlybody', true, '', $lang->mr->approve);?>
|
||||
@@ -108,7 +112,7 @@
|
||||
<?php common::printIcon('mr', 'close', "mr=$MR->id", $MR, 'button', 'off', 'hiddenwin', 'mergeButton');?>
|
||||
<?php common::printIcon('mr', 'edit', "mr=$MR->id", $MR, 'button', 'edit');?>
|
||||
<?php endif;?>
|
||||
<?php if($rawMR->state == 'closed') common::printIcon('mr', 'reopen', "mr=$MR->id", $MR, 'button', 'restart', 'hiddenwin', 'mergeButton'); ?>
|
||||
<?php if($MR->synced and $rawMR->state == 'closed') common::printIcon('mr', 'reopen', "mr=$MR->id", $MR, 'button', 'restart', 'hiddenwin', 'mergeButton'); ?>
|
||||
<?php common::printIcon('mr', 'delete', "mr=$MR->id", $MR, 'button', 'trash', 'hiddenwin');?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,7 +31,8 @@ class product extends control
|
||||
|
||||
/* Get all products, if no, goto the create page. */
|
||||
$this->products = $this->product->getPairs('nocode|all');
|
||||
if($this->app->viewType != 'json' and empty($this->products) and strpos(',create,index,showerrornone,ajaxgetdropmenu,kanban,all', $this->methodName) === false and $this->app->getViewType() != 'mhtml') $this->locate($this->createLink('product', 'create'));
|
||||
$isAPI = ($this->app->viewType == 'json' or (defined('RUN_MODE') and RUN_MODE == 'api'));
|
||||
if(empty($this->products) and strpos(',create,index,showerrornone,ajaxgetdropmenu,kanban', $this->methodName) === false and $this->app->getViewType() != 'mhtml' and !$isAPI) $this->locate($this->createLink('product', 'create'));
|
||||
$this->view->products = $this->products;
|
||||
}
|
||||
|
||||
|
||||
+38
-1
@@ -83,7 +83,7 @@ class repo extends control
|
||||
$repoID = $this->repo->saveState(0, $objectID);
|
||||
if($this->viewType !== 'json') $this->commonAction($repoID, $objectID);
|
||||
|
||||
$repoList = $this->repo->getList(0, $orderBy);
|
||||
$repoList = $this->repo->getList(0, '', $orderBy);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -1177,4 +1177,41 @@ class repo extends control
|
||||
echo html::select('product', array('') + $productPairs, key($productPairs), "class='form-control chosen'");
|
||||
}
|
||||
|
||||
/**
|
||||
* API: get repo by url.
|
||||
*
|
||||
* @param string $type gitlab
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function apiGetRepoByUrl()
|
||||
{
|
||||
$url = urldecode($this->post->repoUrl);
|
||||
$result = $this->repo->getRepoByUrl($url);
|
||||
if($result['result'] == 'fail') return $this->send($result);
|
||||
|
||||
$repo = $result['data'];
|
||||
$fileServer = new stdclass();
|
||||
$fileServer->fileServerUrl = $repo->fileServerUrl;
|
||||
$fileServer->fileServerAccount = $repo->fileServerAccount;
|
||||
$fileServer->fileServerPassword = $repo->fileServerPassword;
|
||||
return $this->send($fileServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* API: get rules.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetRules()
|
||||
{
|
||||
$regRules = $this->repo->processRules();
|
||||
$rawRules = $this->config->repo->rules;
|
||||
|
||||
$data = array();
|
||||
$data['reg'] = $regRules;
|
||||
$data['raw'] = $rawRules;
|
||||
return $this->send(array('status' => 'success', 'rules' => json_encode($data)));
|
||||
}
|
||||
}
|
||||
|
||||
+47
-42
@@ -24,6 +24,7 @@ $lang->repo->repo = 'Repository';
|
||||
$lang->repo->parent = 'Parent File';
|
||||
$lang->repo->branch = 'Branch';
|
||||
$lang->repo->addWebHook = 'Add Webhook';
|
||||
$lang->repo->apiGetRepoByUrl = 'API: Get repo by URL';
|
||||
|
||||
$lang->repo->browseAction = 'Browse Repo';
|
||||
$lang->repo->createAction = 'Create Repo';
|
||||
@@ -48,48 +49,52 @@ $lang->repo->line = 'Line';
|
||||
$lang->repo->expand = 'Unfold';
|
||||
$lang->repo->collapse = 'Fold';
|
||||
|
||||
$lang->repo->id = 'ID';
|
||||
$lang->repo->SCM = 'Type';
|
||||
$lang->repo->name = 'Name';
|
||||
$lang->repo->path = 'Path';
|
||||
$lang->repo->prefix = 'Prefix';
|
||||
$lang->repo->config = 'Config';
|
||||
$lang->repo->desc = 'Description';
|
||||
$lang->repo->account = 'Username';
|
||||
$lang->repo->password = 'Password';
|
||||
$lang->repo->encoding = 'Encoding';
|
||||
$lang->repo->client = 'Client Path';
|
||||
$lang->repo->size = 'Size';
|
||||
$lang->repo->revision = 'Revision';
|
||||
$lang->repo->revisionA = 'Revision';
|
||||
$lang->repo->revisions = 'Revision';
|
||||
$lang->repo->time = 'Date';
|
||||
$lang->repo->committer = 'Committer';
|
||||
$lang->repo->commits = 'Commits';
|
||||
$lang->repo->synced = 'Initialize Sync';
|
||||
$lang->repo->lastSync = 'Last Sync';
|
||||
$lang->repo->deleted = 'Deleted';
|
||||
$lang->repo->commit = 'Commit';
|
||||
$lang->repo->comment = 'Comment';
|
||||
$lang->repo->view = 'View File';
|
||||
$lang->repo->viewA = 'View';
|
||||
$lang->repo->log = 'Revision Log';
|
||||
$lang->repo->blame = 'Blame';
|
||||
$lang->repo->date = 'Date';
|
||||
$lang->repo->diff = 'Diff';
|
||||
$lang->repo->diffAB = 'Diff';
|
||||
$lang->repo->diffAll = 'Diff All';
|
||||
$lang->repo->viewDiff = 'View diff';
|
||||
$lang->repo->allLog = 'All Revisions';
|
||||
$lang->repo->location = 'Location';
|
||||
$lang->repo->file = 'File';
|
||||
$lang->repo->action = 'Action';
|
||||
$lang->repo->code = 'Code';
|
||||
$lang->repo->review = 'Repo Review';
|
||||
$lang->repo->acl = 'Privilege';
|
||||
$lang->repo->group = 'Group';
|
||||
$lang->repo->user = 'User';
|
||||
$lang->repo->info = 'Version Info';
|
||||
$lang->repo->id = 'ID';
|
||||
$lang->repo->SCM = 'Type';
|
||||
$lang->repo->name = 'Name';
|
||||
$lang->repo->path = 'Path';
|
||||
$lang->repo->prefix = 'Prefix';
|
||||
$lang->repo->config = 'Config';
|
||||
$lang->repo->desc = 'Description';
|
||||
$lang->repo->account = 'Username';
|
||||
$lang->repo->password = 'Password';
|
||||
$lang->repo->encoding = 'Encoding';
|
||||
$lang->repo->client = 'Client Path';
|
||||
$lang->repo->size = 'Size';
|
||||
$lang->repo->revision = 'Revision';
|
||||
$lang->repo->revisionA = 'Revision';
|
||||
$lang->repo->revisions = 'Revision';
|
||||
$lang->repo->time = 'Date';
|
||||
$lang->repo->committer = 'Committer';
|
||||
$lang->repo->commits = 'Commits';
|
||||
$lang->repo->synced = 'Initialize Sync';
|
||||
$lang->repo->lastSync = 'Last Sync';
|
||||
$lang->repo->deleted = 'Deleted';
|
||||
$lang->repo->commit = 'Commit';
|
||||
$lang->repo->comment = 'Comment';
|
||||
$lang->repo->view = 'View File';
|
||||
$lang->repo->viewA = 'View';
|
||||
$lang->repo->log = 'Revision Log';
|
||||
$lang->repo->blame = 'Blame';
|
||||
$lang->repo->date = 'Date';
|
||||
$lang->repo->diff = 'Diff';
|
||||
$lang->repo->diffAB = 'Diff';
|
||||
$lang->repo->diffAll = 'Diff All';
|
||||
$lang->repo->viewDiff = 'View diff';
|
||||
$lang->repo->allLog = 'All Revisions';
|
||||
$lang->repo->location = 'Location';
|
||||
$lang->repo->file = 'File';
|
||||
$lang->repo->action = 'Action';
|
||||
$lang->repo->code = 'Code';
|
||||
$lang->repo->review = 'Repo Review';
|
||||
$lang->repo->acl = 'Privilege';
|
||||
$lang->repo->group = 'Group';
|
||||
$lang->repo->user = 'User';
|
||||
$lang->repo->info = 'Version Info';
|
||||
$lang->repo->job = 'Job';
|
||||
$lang->repo->fileServerUrl = 'File Server Url';
|
||||
$lang->repo->fileServerAccount = 'File Server Account';
|
||||
$lang->repo->fileServerPassword = 'File Server Password';
|
||||
|
||||
$lang->repo->title = 'Title';
|
||||
$lang->repo->status = 'Status';
|
||||
|
||||
+47
-42
@@ -24,6 +24,7 @@ $lang->repo->repo = '代码库';
|
||||
$lang->repo->parent = '父文件夹';
|
||||
$lang->repo->branch = '分支';
|
||||
$lang->repo->addWebHook = '添加Webhook';
|
||||
$lang->repo->apiGetRepoByUrl = '接口:通过URL获取版本库';
|
||||
|
||||
$lang->repo->browseAction = '浏览版本库';
|
||||
$lang->repo->createAction = '创建版本库';
|
||||
@@ -48,48 +49,52 @@ $lang->repo->line = '行';
|
||||
$lang->repo->expand = '点击展开';
|
||||
$lang->repo->collapse = '点击折叠';
|
||||
|
||||
$lang->repo->id = 'ID';
|
||||
$lang->repo->SCM = '类型';
|
||||
$lang->repo->name = '名称';
|
||||
$lang->repo->path = '地址';
|
||||
$lang->repo->prefix = '地址扩展';
|
||||
$lang->repo->config = '配置目录';
|
||||
$lang->repo->desc = '描述';
|
||||
$lang->repo->account = '用户名';
|
||||
$lang->repo->password = '密码';
|
||||
$lang->repo->encoding = '编码';
|
||||
$lang->repo->client = '客户端';
|
||||
$lang->repo->size = '大小';
|
||||
$lang->repo->revision = '查看版本';
|
||||
$lang->repo->revisionA = '版本';
|
||||
$lang->repo->revisions = '版本';
|
||||
$lang->repo->time = '提交时间';
|
||||
$lang->repo->committer = '作者';
|
||||
$lang->repo->commits = '提交数';
|
||||
$lang->repo->synced = '初始化同步';
|
||||
$lang->repo->lastSync = '最后同步时间';
|
||||
$lang->repo->deleted = '已删除';
|
||||
$lang->repo->commit = '提交';
|
||||
$lang->repo->comment = '注释';
|
||||
$lang->repo->view = '查看文件';
|
||||
$lang->repo->viewA = '查看';
|
||||
$lang->repo->log = '版本历史';
|
||||
$lang->repo->blame = '追溯';
|
||||
$lang->repo->date = '日期';
|
||||
$lang->repo->diff = '比较差异';
|
||||
$lang->repo->diffAB = '比较';
|
||||
$lang->repo->diffAll = '全部比较';
|
||||
$lang->repo->viewDiff = '查看差异';
|
||||
$lang->repo->allLog = '所有版本';
|
||||
$lang->repo->location = '位置';
|
||||
$lang->repo->file = '文件';
|
||||
$lang->repo->action = '操作';
|
||||
$lang->repo->code = '代码';
|
||||
$lang->repo->review = '评审';
|
||||
$lang->repo->acl = '权限';
|
||||
$lang->repo->group = '分组';
|
||||
$lang->repo->user = '用户';
|
||||
$lang->repo->info = '版本信息';
|
||||
$lang->repo->id = 'ID';
|
||||
$lang->repo->SCM = '类型';
|
||||
$lang->repo->name = '名称';
|
||||
$lang->repo->path = '地址';
|
||||
$lang->repo->prefix = '地址扩展';
|
||||
$lang->repo->config = '配置目录';
|
||||
$lang->repo->desc = '描述';
|
||||
$lang->repo->account = '用户名';
|
||||
$lang->repo->password = '密码';
|
||||
$lang->repo->encoding = '编码';
|
||||
$lang->repo->client = '客户端';
|
||||
$lang->repo->size = '大小';
|
||||
$lang->repo->revision = '查看版本';
|
||||
$lang->repo->revisionA = '版本';
|
||||
$lang->repo->revisions = '版本';
|
||||
$lang->repo->time = '提交时间';
|
||||
$lang->repo->committer = '作者';
|
||||
$lang->repo->commits = '提交数';
|
||||
$lang->repo->synced = '初始化同步';
|
||||
$lang->repo->lastSync = '最后同步时间';
|
||||
$lang->repo->deleted = '已删除';
|
||||
$lang->repo->commit = '提交';
|
||||
$lang->repo->comment = '注释';
|
||||
$lang->repo->view = '查看文件';
|
||||
$lang->repo->viewA = '查看';
|
||||
$lang->repo->log = '版本历史';
|
||||
$lang->repo->blame = '追溯';
|
||||
$lang->repo->date = '日期';
|
||||
$lang->repo->diff = '比较差异';
|
||||
$lang->repo->diffAB = '比较';
|
||||
$lang->repo->diffAll = '全部比较';
|
||||
$lang->repo->viewDiff = '查看差异';
|
||||
$lang->repo->allLog = '所有版本';
|
||||
$lang->repo->location = '位置';
|
||||
$lang->repo->file = '文件';
|
||||
$lang->repo->action = '操作';
|
||||
$lang->repo->code = '代码';
|
||||
$lang->repo->review = '评审';
|
||||
$lang->repo->acl = '权限';
|
||||
$lang->repo->group = '分组';
|
||||
$lang->repo->user = '用户';
|
||||
$lang->repo->info = '版本信息';
|
||||
$lang->repo->job = '构建任务';
|
||||
$lang->repo->fileServerUrl = '预合并后上传服务器目录';
|
||||
$lang->repo->fileServerAccount = '文件服务器登录用户名';
|
||||
$lang->repo->fileServerPassword = '文件服务器登录密码';
|
||||
|
||||
$lang->repo->title = '标题';
|
||||
$lang->repo->status = '状态';
|
||||
|
||||
+81
-1
@@ -118,15 +118,17 @@ class repoModel extends model
|
||||
* Get repo list.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $SCM Subversion|Git|Gitlab
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getList($projectID = 0, $orderBy = 'id_desc', $pager = null)
|
||||
public function getList($projectID = 0, $SCM = '', $orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
$repos = $this->dao->select('*')->from(TABLE_REPO)
|
||||
->where('deleted')->eq('0')
|
||||
->beginIF($SCM)->andWhere('SCM')->eq($SCM)->fi()
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
@@ -396,6 +398,84 @@ class repoModel extends model
|
||||
return $repo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repo by url.
|
||||
*
|
||||
* @param string $url
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getRepoByUrl($url)
|
||||
{
|
||||
if(empty($url)) return array('result' => 'fail', 'message' => 'Url is empty.');
|
||||
|
||||
$parsedUrl = parse_url($url);
|
||||
|
||||
$isSSH = $parsedUrl['scheme'] == 'ssh';
|
||||
$baseURL = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . (isset($parsedUrl['port']) ? ":{$parsedUrl['port']}" : '');
|
||||
|
||||
/* Get gitlabs by URL. */
|
||||
$gitlabs = $this->dao->select('*')->from(TABLE_PIPELINE)->where('type')->eq('gitlab')
|
||||
->beginIF($isSSH)->andWhere('url')->like("%{$parsedUrl['host']}%")->fi()
|
||||
->beginIF(!$isSSH)->andWhere('url')->eq($baseURL)->fi()
|
||||
->andWhere('deleted')->eq('0')
|
||||
->orderBy('id_desc')
|
||||
->fetchAll('id');
|
||||
|
||||
/* Convert to id by url. */
|
||||
$this->loadModel('gitlab');
|
||||
$url = strtolower($url);
|
||||
$matches = array();
|
||||
foreach($gitlabs as $gitlabID => $gitlab)
|
||||
{
|
||||
$matched = new stdclass();
|
||||
$matched->gitlab = 0;
|
||||
$matched->project = 0;
|
||||
|
||||
$projects = $this->gitlab->apiGetProjects($gitlabID);
|
||||
foreach($projects as $project)
|
||||
{
|
||||
if((!$isSSH and strtolower($project->http_url_to_repo) == $url) or ($isSSH and strtolower($project->ssh_url_to_repo) == $url))
|
||||
{
|
||||
$matched->gitlab = $gitlabID;
|
||||
$matched->project = $project->id;
|
||||
|
||||
$matches[] = $matched;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($matches)) return array('result' => 'fail', 'message' => 'No matched gitlab.');
|
||||
|
||||
$conditions = array();
|
||||
foreach($matches as $matched) $conditions[] = "(`client`='$matched->gitlab' and `path`='$matched->project')";
|
||||
$conditions = '(' . join(' OR ', $conditions). ')';
|
||||
|
||||
$matchedRepos = $this->dao->select('*')->from(TABLE_REPO)->where('SCM')->eq('Gitlab')
|
||||
->andWhere($conditions)
|
||||
->andWhere('deleted')->eq('0')
|
||||
->orderBy('id_desc')
|
||||
->fetchAll();
|
||||
if(empty($matchedRepos)) return array('result' => 'fail', 'message' => 'No matched gitlab.');
|
||||
|
||||
$matchedRepo = '';
|
||||
foreach($matchedRepos as $repo)
|
||||
{
|
||||
if(!empty($repo->preMerge))
|
||||
{
|
||||
$matchedRepo = $repo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(empty($matchedRepo)) return array('result' => 'fail', 'message' => 'Matched gitlab is not open pre merge.');
|
||||
if(empty($matchedRepo->job)) return array('result' => 'fail', 'message' => 'No linked job.');
|
||||
|
||||
$job = $this->dao->select('*')->from(TABLE_JOB)->where('id')->eq($matchedRepo->job)->andWhere('deleted')->eq(0)->fetch();
|
||||
if(empty($job)) return array('result' => 'fail', 'message' => 'Linked job is not exists.');
|
||||
|
||||
$matchedRepo->job = $job;
|
||||
return array('result' => 'success', 'data' => $matchedRepo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by id list.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::apiGetTags();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过gitlabID,projectID,获取GitLab标签列表 >> 2021/12/20
|
||||
通过gitlabID,projectID,获取GitLab标签数量 >> 1
|
||||
当前项目没有标签时,获取GitLab标签列表 >> 0
|
||||
当gitlabID存在,projectID不存在时,获取GitLab标签列表 >> 404 Project Not Found
|
||||
当gitlabID,projectID都为0时,获取GitLab标签列表 >> return empty
|
||||
通过gitlabID,projectID,按标签名升序获取GitLab标签列表 >> with_cicredentials
|
||||
通过gitlabID,projectID,搜索字符'zentaopms_15.2_20210720'获取GitLab标签列表 >> zentaopms_15.2_20210720
|
||||
通过gitlabID,projectID,每页20条记录,分页获取第二页GitLab标签列表 >> zentaopms_2.0_stable_20110503
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID);
|
||||
r($result) && p('0:name') && e('2021/12/20'); //通过gitlabID,projectID,获取GitLab标签列表
|
||||
r(count($result)) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签数量
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1570;
|
||||
r(count($gitlab->apiGetTags($gitlabID, $projectID))) && p() && e(0); //当前项目没有标签时,获取GitLab标签列表
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 0;
|
||||
r($gitlab->apiGetTags($gitlabID, $projectID)) && p('message') && e('404 Project Not Found'); //通过gitlabID,projectID,获取GitLab标签列表
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取GitLab标签列表
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 964;
|
||||
$orderBy = 'name_asc';
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID, $orderBy);
|
||||
r($result) && p('0:name') && e('with_cicredentials'); //通过gitlabID,projectID,按标签名升序获取GitLab标签列表
|
||||
|
||||
$keyword = 'zentaopms_15.2_20210720';
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID, $orderBy, $keyword);
|
||||
r($result) && p('0:name') && e('zentaopms_15.2_20210720'); //通过gitlabID,projectID,搜索字符'zentaopms_15.2_20210720'获取GitLab标签列表
|
||||
|
||||
$tester->app->loadClass('pager', $static = true);
|
||||
$pager = new pager(0, 20, 2);
|
||||
$result = $gitlab->apiGetTags($gitlabID, $projectID, $orderBy, '', $pager);
|
||||
r($result) && p('0:name') && e('zentaopms_2.0_stable_20110503'); //通过gitlabID,projectID,每页20条记录,分页获取第二页GitLab标签列表
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::createTag();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的gitlabID、projectID、标签创建GitLab标签 >> return false
|
||||
使用空的gitlabID、projectID,正确的标签创建GitLab标签 >> return false
|
||||
使用正确的gitlabID、标签信息,错误的projectID创建标签 >> return false
|
||||
使用正确的gitlabID,projectID,标签创建GitLab标签 >> return true
|
||||
使用重复的标签信息创建标签 >> return false
|
||||
|
||||
*/
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 0;
|
||||
$projectID = 0;
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID,projectID,标签对象创建GitLab标签
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['tag_name'] = 'test_tag17';
|
||||
$_POST['ref'] = 'master';
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用空的gitlabID、projectID,正确的标签对象创建GitLab标签
|
||||
|
||||
dao::$errors = array();
|
||||
$gitlabID = 1;
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID、标签信息,错误的projectID创建标签
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,标签对象正确创建GitLab标签
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用重复的标签信息创建标签
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 mrModel::apiCreate();
|
||||
cid=0
|
||||
pid=0
|
||||
|
||||
使用空的RepoUrl数据创建 >> fail
|
||||
使用正确的RepoUrl,错误的分支数据创建mr请求 >> fail
|
||||
使用源分支和目标分支一样的数据创建mr请求 >> success
|
||||
使用正确的数据创建mr请求 >> success
|
||||
|
||||
*/
|
||||
|
||||
$mrModel = $tester->loadModel('mr');
|
||||
|
||||
$_POST = array(
|
||||
'data' => array()
|
||||
);
|
||||
|
||||
$_POST['data']['RepoUrl'] = '';
|
||||
$result = $mrModel->apiCreate();
|
||||
if(!$result) $result = 'fail';
|
||||
r($result) && p() && e('fail'); //使用空的RepoUrl数据创建
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['data']['RepoUrl'] = 'http://192.168.1.161:51080/root/azalea723test.git';
|
||||
$_POST['data']['DiffMsg'] = '';
|
||||
$_POST['data']['RepoSrcBranch'] = '';
|
||||
$_POST['data']['RepoDistBranch'] = '';
|
||||
$_POST['data']['MergeStatus'] = '1';
|
||||
$result = $mrModel->apiCreate();
|
||||
if(!$result) $result = 'fail';
|
||||
r($result) && p() && e('fail'); //使用正确的RepoUrl,错误的分支数据创建mr请求
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['data']['RepoSrcBranch'] = 'master';
|
||||
$_POST['data']['RepoDistBranch'] = 'master';
|
||||
$result = $mrModel->apiCreate();
|
||||
if($result) $result = 'success';
|
||||
r($result) && p() && e('success'); //使用源分支和目标分支一样的数据创建mr请求
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['data']['RepoSrcBranch'] = 'branch-08';
|
||||
$_POST['data']['RepoDistBranch'] = 'master';
|
||||
$result = $mrModel->apiCreate();
|
||||
if($result) $result = 'success';
|
||||
r($result) && p() && e('success'); //使用正确的数据创建mr请求
|
||||
@@ -23,15 +23,16 @@ $_POST['repoID'] = 0;
|
||||
$result = $mrModel->create();
|
||||
r($result) && p('message[gitlabID]:0') && e('『GitLab』不能为空。'); //使用空的repoID, gitlabID。创建mr。
|
||||
|
||||
$_POST['gitlabID'] = 1;
|
||||
$_POST['sourceProject'] = 42;
|
||||
$_POST['sourceBranch'] = 'branch-08';
|
||||
$_POST['targetProject'] = 42;
|
||||
$_POST['targetBranch'] = 'branch-09';
|
||||
$_POST['title'] = 'test_create';
|
||||
$_POST['description'] = 'test_create';
|
||||
$_POST['repoID'] = 1;
|
||||
$_POST['assignee'] = '';
|
||||
$_POST['gitlabID'] = 1;
|
||||
$_POST['sourceProject'] = 42;
|
||||
$_POST['sourceBranch'] = 'branch-08';
|
||||
$_POST['targetProject'] = 42;
|
||||
$_POST['targetBranch'] = 'branch-09';
|
||||
$_POST['title'] = 'test_create';
|
||||
$_POST['description'] = 'test_create';
|
||||
$_POST['repoID'] = 1;
|
||||
$_POST['assignee'] = '';
|
||||
$_POST['removeSourceBranch'] = '1';
|
||||
$result = $mrModel->create();
|
||||
if($result['result'] == 'success') $result = 'success';
|
||||
$result = preg_match('/通过API创建合并请求失败,失败原因:存在另外一个同样的合并请求在源项目分支中: !([0-9]+)/', $result['message'], $matches); //检查错误原因是否是已存在一样的mr请求
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 mrModel::update();
|
||||
cid=0
|
||||
pid=0
|
||||
|
||||
POST数据正确修改MR描述 >> success
|
||||
使用title为空的数据mr请求 >> 『名称』不能为空。
|
||||
|
||||
*/
|
||||
|
||||
$mrModel = $tester->loadModel('mr');
|
||||
$MRID = 1;
|
||||
|
||||
$_POST = array();
|
||||
$_POST['targetBranch'] = 'master';
|
||||
$_POST['title'] = 'Test MR';
|
||||
$_POST['description'] = date("Y-m-d H:i:s");
|
||||
$_POST['repoID'] = 1;
|
||||
$_POST['assignee'] = '';
|
||||
$_POST['removeSourceBranch'] = '0';
|
||||
$result = $mrModel->update($MRID);
|
||||
if($result['result'] == 'success') $result = 'success';
|
||||
r($result) && p() && e('success'); //POST数据正确修改MR描述
|
||||
|
||||
$_POST['title'] = '';
|
||||
$result = $mrModel->update($MRID);
|
||||
r($result) && p('message[title]:0') && e('『名称』不能为空。'); //使用title为空的数据mr请求
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 repoModel::getRepoByUrl();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用空的url >> Url is empty.
|
||||
使用错误的url >> No matched gitlab.
|
||||
使用正确的url >> return normal
|
||||
|
||||
*/
|
||||
|
||||
$repoModel = $tester->loadModel('repo');
|
||||
|
||||
$url = '';
|
||||
$result = $repoModel->getRepoByUrl($url);
|
||||
r($result) && p('message') && e('Url is empty.'); //使用空的MR
|
||||
|
||||
$url = 'http://192.168.1.161:51080/gitlab-instance-f9325ed1/azalea723test.git';
|
||||
$result = $repoModel->getRepoByUrl($url);
|
||||
r($result) && p('message') && e('No matched gitlab.'); //使用错误的MR
|
||||
|
||||
$url = 'http://192.168.1.161:51080/root/azalea723test.git';
|
||||
$result = $repoModel->getRepoByUrl($url);
|
||||
if(!empty($result))
|
||||
{
|
||||
if($result['result'] == 'fail' and $result['message'] != 'No matched gitlab.') $result = 'return normal';
|
||||
if(is_array($result) and $result['result'] == 'success') $result = 'return normal';
|
||||
}
|
||||
r($result) && p() && e('return normal'); //使用正确的MR
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user