From b4685be3dedf11a8ff5d688ef16b7170cd7325df Mon Sep 17 00:00:00 2001 From: zenggang Date: Tue, 7 Dec 2021 08:15:04 +0000 Subject: [PATCH 01/66] * Finish task#45500 --- module/gitlab/control.php | 46 ++++++++++++++++ module/gitlab/lang/en.php | 6 +++ module/gitlab/lang/zh-cn.php | 6 +++ module/gitlab/view/browsebranch.html.php | 64 +++++++++++++++++++++++ module/gitlab/view/browseproject.html.php | 1 + module/group/lang/resource.php | 2 + 6 files changed, 125 insertions(+) create mode 100644 module/gitlab/view/browsebranch.html.php diff --git a/module/gitlab/control.php b/module/gitlab/control.php index e56cae595d..ed54708167 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -712,6 +712,52 @@ class gitlab extends control die(js::alert($reponse->message)); } + /** + * Browse gitlab branch. + * + * @param int $gitlabID + * @param int $projectID + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function browseBranch($gitlabID, $projectID, $orderBy = 'name_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1) + { + $branchList = array(); + $result = $this->gitlab->apiGetBranches($gitlabID, $projectID); + foreach($result as $gitlabBranch) + { + $branch = new stdClass(); + $branch->name = $gitlabBranch->name; + $branch->lastCommitter = $gitlabBranch->commit->committer_name; + $branch->lastCommittedDate = date('Y-m-d H:i:s', strtotime($gitlabBranch->commit->committed_date)); + + $branchList[] = $branch; + } + + /* Data sort. */ + list($order, $sort) = explode('_', $orderBy); + array_multisort(array_column($branchList, $order), $sort == 'desc' ? SORT_DESC : SORT_ASC, $branchList); + + /* Pager. */ + $this->app->loadClass('pager', $static = true); + $recTotal = count($branchList); + $pager = new pager($recTotal, $recPerPage, $pageID); + $branchList = array_chunk($branchList, $pager->recPerPage); + + $this->view->gitlab = $this->gitlab->getByID($gitlabID); + $this->view->pager = $pager; + $this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browseBranch; + $this->view->gitlabID = $gitlabID; + $this->view->projectID = $projectID; + $this->view->gitlabBranchList = empty($branchList) ? $branchList: $branchList[$pageID - 1]; + $this->view->orderBy = $orderBy; + $this->display(); + } + /** * Import gitlab issue to zentaopms. * diff --git a/module/gitlab/lang/en.php b/module/gitlab/lang/en.php index 07c7ad4e7f..60c92fd148 100644 --- a/module/gitlab/lang/en.php +++ b/module/gitlab/lang/en.php @@ -30,6 +30,7 @@ $lang->gitlab->gitlabProject = "GitLab Project"; $lang->gitlab->browseProject = "GitLab Project List"; $lang->gitlab->browseUser = "User List"; $lang->gitlab->browseGroup = "Group List"; +$lang->gitlab->browseBranch = "Branch List"; $lang->gitlab->gitlabIssue = "GitLab Issue"; $lang->gitlab->zentaoProduct = 'Zentao Product'; $lang->gitlab->objectType = 'Type'; // task, bug, story @@ -43,6 +44,7 @@ $lang->gitlab->deleteGroup = 'Delete group'; $lang->gitlab->createUser = 'Create user'; $lang->gitlab->editUser = 'Edit user'; $lang->gitlab->deleteUser = 'Delete user'; +$lang->gitlab->createBranch = 'Add branch'; $lang->gitlab->manageGroupMembers = 'Manage group member'; $lang->gitlab->createWebhook = 'Create Webhook'; @@ -58,6 +60,10 @@ $lang->gitlab->desc = 'Description'; $lang->gitlab->tokenFirst = 'When the Token is not empty, the Token will be used first'; $lang->gitlab->tips = 'When using a password, please disable the "Prevent cross-site request forgery" option in the GitLab global security settings.'; +$lang->gitlab->branchName = 'Branch Name'; +$lang->gitlab->branchLastCommitter = 'Last Committer'; +$lang->gitlab->branchLastCommittedDate = 'Last Committed Date'; + $lang->gitlab->placeholder = new stdclass; $lang->gitlab->placeholder->name = ''; $lang->gitlab->placeholder->url = "Please fill in the access address of the GitLab Server homepage, as: https://gitlab.zentao.net."; diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index d911572925..4d226bec95 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -30,6 +30,7 @@ $lang->gitlab->gitlabProject = "{$lang->gitlab->common}项目"; $lang->gitlab->browseProject = "{$lang->gitlab->common}项目列表"; $lang->gitlab->browseUser = "用户列表"; $lang->gitlab->browseGroup = "群组列表"; +$lang->gitlab->browseBranch = "分支列表"; $lang->gitlab->gitlabIssue = "{$lang->gitlab->common} issue"; $lang->gitlab->zentaoProduct = '禅道产品'; $lang->gitlab->objectType = '类型'; // task, bug, story @@ -43,6 +44,7 @@ $lang->gitlab->deleteGroup = '删除群组'; $lang->gitlab->createUser = '添加用户'; $lang->gitlab->editUser = '编辑用户'; $lang->gitlab->deleteUser = '删除用户'; +$lang->gitlab->createBranch = '添加分支'; $lang->gitlab->manageGroupMembers = '群组成员管理'; $lang->gitlab->createWebhook = '创建Webhook'; @@ -58,6 +60,10 @@ $lang->gitlab->desc = '描述'; $lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。'; $lang->gitlab->tips = '使用密码时,请在GitLab全局安全设置中禁用"防止跨站点请求伪造"选项。'; +$lang->gitlab->branchName = '分支名'; +$lang->gitlab->branchLastCommitter = '最后提交'; +$lang->gitlab->branchLastCommittedDate = '最后修改时间'; + $lang->gitlab->placeholder = new stdclass; $lang->gitlab->placeholder->name = ''; $lang->gitlab->placeholder->url = "请填写GitLab Server首页的访问地址,如:https://gitlab.zentao.net。"; diff --git a/module/gitlab/view/browsebranch.html.php b/module/gitlab/view/browsebranch.html.php new file mode 100644 index 0000000000..4b48e77368 --- /dev/null +++ b/module/gitlab/view/browsebranch.html.php @@ -0,0 +1,64 @@ + + * @package gitlab + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +recTotal}&recPerPage={$pager->recPerPage}&pageID=1")?> + + + +
+

+ noData;?> + + createLink('gitlab', 'createBranch', "gitlabID=$gitlabID"), " " . $lang->gitlab->createBranch, '', "class='btn btn-info'");?> + +

+
+ +
+
+ + recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?> + + + + + + + + + + $gitlabBranch): ?> + + + + + + + + +
gitlab->branchName);?>gitlab->branchLastCommitter;?>gitlab->branchLastCommittedDate);?>actions;?>
name;?>lastCommitter;?>lastCommittedDate?> +
+ + + +
+
+ + diff --git a/module/gitlab/view/browseproject.html.php b/module/gitlab/view/browseproject.html.php index 40eea5877c..56eadf0b97 100644 --- a/module/gitlab/view/browseproject.html.php +++ b/module/gitlab/view/browseproject.html.php @@ -67,6 +67,7 @@ last_activity_at, 0, 10);?> id", " ", '', "title={$lang->gitlab->browseBranch} class='btn btn-primary'"); common::printLink('gitlab', 'editProject', "gitlabID=$gitlabID&projectID=$gitlabProject->id", " ", '', "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"), '', 'hiddenwin', "title='{$lang->gitlab->deleteProject}' class='btn'"); ?> diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index f4abbb41bb..14d563691a 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -1248,6 +1248,7 @@ $lang->resource->gitlab->deleteUser = 'deleteUser'; $lang->resource->gitlab->webhook = 'webhook'; $lang->resource->gitlab->createWebhook = 'createWebhook'; $lang->resource->gitlab->manageProjectMembers = 'manageProjectMembers'; +$lang->resource->gitlab->browseBranch = 'browseBranch'; $lang->gitlab->methodOrder[5] = 'browse'; $lang->gitlab->methodOrder[10] = 'create'; @@ -1272,6 +1273,7 @@ $lang->gitlab->methodOrder[105] = 'deleteUser'; $lang->gitlab->methodOrder[110] = 'webhook'; $lang->gitlab->methodOrder[115] = 'createWebhook'; $lang->gitlab->methodOrder[120] = 'manageProjectMembers'; +$lang->gitlab->methodOrder[125] = 'browseBranch'; /* merge request. */ $lang->resource->mr = new stdclass(); From cf280763b2d20a51207d0df92cf6246ce49a46d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Tue, 7 Dec 2021 08:21:33 +0000 Subject: [PATCH 02/66] Merge branch 'sprint/devops16_liyuchun_45491' into 'master' * Finish task #45491. See merge request easycorp/zentaopms!803 (cherry picked from commit ff06288dc8614345883d921d7a8ba6556aac4d16) b11dd3af * Finish task #45491. --- module/action/lang/en.php | 1 + module/action/lang/zh-cn.php | 1 + module/block/lang/en.php | 1 + module/block/lang/zh-cn.php | 1 + module/block/view/dynamic.html.php | 3 +- module/gitlab/config.php | 3 ++ module/gitlab/control.php | 33 +++++++++++++++++ module/gitlab/lang/en.php | 18 +++++++--- module/gitlab/lang/zh-cn.php | 18 +++++++--- module/gitlab/model.php | 45 ++++++++++++++++++++++++ module/gitlab/view/createbranch.html.php | 44 +++++++++++++++++++++++ module/group/lang/resource.php | 1 + module/repo/control.php | 1 + module/repo/view/browse.html.php | 1 + 14 files changed, 162 insertions(+), 9 deletions(-) create mode 100644 module/gitlab/view/createbranch.html.php diff --git a/module/action/lang/en.php b/module/action/lang/en.php index d30f55cafa..93ba842862 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -121,6 +121,7 @@ $lang->action->objectTypes['mr'] = 'Merge Request'; $lang->action->objectTypes['gitlabproject'] = 'GitLab Project'; $lang->action->objectTypes['gitlabuser'] = 'GitLab User'; $lang->action->objectTypes['gitlabgroup'] = 'GitLab Group'; +$lang->action->objectTypes['gitlabbranch'] = 'GitLab Branch'; /* Used to describe operation history. */ $lang->action->desc = new stdclass(); diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index c43e723f00..48f20af743 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -121,6 +121,7 @@ $lang->action->objectTypes['mr'] = '合并请求'; $lang->action->objectTypes['gitlabproject'] = 'GitLab项目'; $lang->action->objectTypes['gitlabuser'] = 'GitLab用户'; $lang->action->objectTypes['gitlabgroup'] = 'GitLab群组'; +$lang->action->objectTypes['gitlabbranch'] = 'GitLab分支'; /* 用来描述操作历史记录。*/ $lang->action->desc = new stdclass(); diff --git a/module/block/lang/en.php b/module/block/lang/en.php index ce31de4f53..b0a9a555e3 100644 --- a/module/block/lang/en.php +++ b/module/block/lang/en.php @@ -91,6 +91,7 @@ $lang->block->refresh = 'Refresh'; $lang->block->nbsp = ' '; $lang->block->hidden = 'Hide'; $lang->block->dynamicInfo = "%s %s %s %s %s"; +$lang->block->noLinkDynamic = "%s %s %s %s %s"; $lang->block->cannotPlaceInLeft = 'Cannot place the block at left side.'; $lang->block->cannotPlaceInRight = 'Cannot place the block at right side.'; diff --git a/module/block/lang/zh-cn.php b/module/block/lang/zh-cn.php index ac77206f01..e5d8deface 100644 --- a/module/block/lang/zh-cn.php +++ b/module/block/lang/zh-cn.php @@ -91,6 +91,7 @@ $lang->block->refresh = '刷新'; $lang->block->nbsp = ''; $lang->block->hidden = '隐藏'; $lang->block->dynamicInfo = "%s %s %s %s %s"; +$lang->block->noLinkDynamic = "%s %s %s %s %s"; $lang->block->cannotPlaceInLeft = '此区块无法放置在左侧。'; $lang->block->cannotPlaceInRight = '此区块无法放置在右侧。'; diff --git a/module/block/view/dynamic.html.php b/module/block/view/dynamic.html.php index 2447f62507..215bb804d3 100644 --- a/module/block/view/dynamic.html.php +++ b/module/block/view/dynamic.html.php @@ -15,7 +15,8 @@ if($action->action == 'login' or $action->action == 'logout') $action->objectName = $action->objectLabel = ''; $class = $action->major ? "class='active'" : ''; echo "
  • "; - printf($lang->block->dynamicInfo, $action->date, $user, $action->actionLabel, $action->objectLabel, $action->objectLink, $action->objectName, $action->objectName); + if($action->objectLink) printf($lang->block->dynamicInfo, $action->date, $user, $action->actionLabel, $action->objectLabel, $action->objectLink, $action->objectName, $action->objectName); + if(!$action->objectLink) printf($lang->block->noLinkDynamic, $action->date, $action->objectName, $user, $action->actionLabel, $action->objectLabel, $action->objectName); echo "
  • "; $i++; } diff --git a/module/gitlab/config.php b/module/gitlab/config.php index 5f41d70ceb..bd6760c7cc 100644 --- a/module/gitlab/config.php +++ b/module/gitlab/config.php @@ -5,6 +5,9 @@ $config->gitlab->create->requiredFields = 'name,url,token'; $config->gitlab->edit = new stdclass; $config->gitlab->edit->requiredFields = 'name,url,token'; +$config->gitlab->createbranch = new stdclass; +$config->gitlab->createbranch->requiredFields = 'branch,ref'; + $config->gitlab->labelPattern = new stdclass; $config->gitlab->labelPattern->task = '/^zentao_task\/\d+$/'; $config->gitlab->labelPattern->bug = '/^zentao_bug\/\d+$/'; diff --git a/module/gitlab/control.php b/module/gitlab/control.php index e56cae595d..b1738b51fd 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -712,6 +712,39 @@ class gitlab extends control die(js::alert($reponse->message)); } + /** + * Creat a gitlab branch. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return void + */ + public function createBranch($gitlabID, $projectID) + { + if($_POST) + { + $this->gitlab->createBranch($gitlabID, $projectID); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + $locate = $this->session->gitlabBranchList ? $this->session->gitlabBranchList : inlink('browseBranch', "gitlibID=$gitlabID&projectID=$projectID"); + return $this->send(array('result' => 'success', 'message' => $this->lang->gitlab->createSuccess, 'locate' => $locate)); + } + + /* Get branches by api. */ + $branches = $this->gitlab->apiGetBranches($gitlabID, $projectID); + if(!is_array($branches)) $branches= array(); + + $branchPairs = array(); + foreach($branches as $branch) $branchPairs[$branch->name] = $branch->name; + + $this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->createBranch; + $this->view->gitlabID = $gitlabID; + $this->view->projectID = $projectID; + $this->view->branchPairs = $branchPairs; + $this->display(); + } + /** * Import gitlab issue to zentaopms. * diff --git a/module/gitlab/lang/en.php b/module/gitlab/lang/en.php index 07c7ad4e7f..3224521a51 100644 --- a/module/gitlab/lang/en.php +++ b/module/gitlab/lang/en.php @@ -37,6 +37,7 @@ $lang->gitlab->manageProjectMembers = 'Manage project member'; $lang->gitlab->createProject = 'Create GitLab project'; $lang->gitlab->editProject = 'Eidt GitLab project'; $lang->gitlab->deleteProject = 'Delete GitLab project'; +$lang->gitlab->createBranch = 'Create Branch'; $lang->gitlab->createGroup = 'Create group'; $lang->gitlab->editGroup = 'Edit group'; $lang->gitlab->deleteGroup = 'Delete group'; @@ -53,10 +54,12 @@ $lang->gitlab->token = 'Token'; $lang->gitlab->defaultProject = 'Default Project'; $lang->gitlab->private = 'MD5 Verify'; -$lang->gitlab->lblCreate = 'Create GitLab Server'; -$lang->gitlab->desc = 'Description'; -$lang->gitlab->tokenFirst = 'When the Token is not empty, the Token will be used first'; -$lang->gitlab->tips = 'When using a password, please disable the "Prevent cross-site request forgery" option in the GitLab global security settings.'; +$lang->gitlab->lblCreate = 'Create GitLab Server'; +$lang->gitlab->desc = 'Description'; +$lang->gitlab->tokenFirst = 'When the Token is not empty, the Token will be used first'; +$lang->gitlab->tips = 'When using a password, please disable the "Prevent cross-site request forgery" option in the GitLab global security settings.'; +$lang->gitlab->emptyError = "cannot be empty"; +$lang->gitlab->createSuccess = "Create success"; $lang->gitlab->placeholder = new stdclass; $lang->gitlab->placeholder->name = ''; @@ -82,11 +85,13 @@ $lang->gitlab->apiError[0] = 'internal is not allowed in a private group.'; $lang->gitlab->apiError[1] = 'public is not allowed in a private group.'; $lang->gitlab->apiError[2] = 'is too short (minimum is 8 characters)'; $lang->gitlab->apiError[3] = "can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"; +$lang->gitlab->apiError[4] = 'Branch already exists'; $lang->gitlab->errorLang[0] = 'You cannot set Internal as its Visibility Level, if it is private in GitLab.'; $lang->gitlab->errorLang[1] = 'You cannot set Public as its Visibility Level, if it is private in GitLab.'; $lang->gitlab->errorLang[2] = 'Password is too short (minimum is 8 characters)'; $lang->gitlab->errorLang[3] = 'It should contain only letters, digits, underscore, hyphen and period. It should not start with hypen, or end with .git or .atom.'; +$lang->gitlab->errorLang[4] = 'Branch already exists.'; $lang->gitlab->project = new stdclass; $lang->gitlab->project->id = "Project ID"; @@ -171,3 +176,8 @@ $lang->gitlab->group->memberName = 'Account'; $lang->gitlab->group->memberAccessLevel = 'Access Level'; $lang->gitlab->group->memberExpiresAt = 'Expiration time'; $lang->gitlab->group->repeatError = "Group members cannot be added repeatedly"; + +$lang->gitlab->branch = new stdclass(); +$lang->gitlab->branch->name = 'Branch Name'; +$lang->gitlab->branch->from = 'Create from'; +$lang->gitlab->branch->create = 'Create'; diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index d911572925..d23f272d0d 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -37,6 +37,7 @@ $lang->gitlab->manageProjectMembers = '项目成员管理'; $lang->gitlab->createProject = '添加GitLab项目'; $lang->gitlab->editProject = '编辑GitLab项目'; $lang->gitlab->deleteProject = '删除GitLab项目'; +$lang->gitlab->createBranch = '添加分支'; $lang->gitlab->createGroup = '添加群组'; $lang->gitlab->editGroup = '编辑群组'; $lang->gitlab->deleteGroup = '删除群组'; @@ -53,10 +54,12 @@ $lang->gitlab->token = 'Token'; $lang->gitlab->defaultProject = '默认项目'; $lang->gitlab->private = 'MD5验证'; -$lang->gitlab->lblCreate = '添加GitLab服务器'; -$lang->gitlab->desc = '描述'; -$lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。'; -$lang->gitlab->tips = '使用密码时,请在GitLab全局安全设置中禁用"防止跨站点请求伪造"选项。'; +$lang->gitlab->lblCreate = '添加GitLab服务器'; +$lang->gitlab->desc = '描述'; +$lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。'; +$lang->gitlab->tips = '使用密码时,请在GitLab全局安全设置中禁用"防止跨站点请求伪造"选项。'; +$lang->gitlab->emptyError = "不能为空"; +$lang->gitlab->createSuccess = "创建成功"; $lang->gitlab->placeholder = new stdclass; $lang->gitlab->placeholder->name = ''; @@ -82,11 +85,13 @@ $lang->gitlab->apiError[0] = 'internal is not allowed in a private group.'; $lang->gitlab->apiError[1] = 'public is not allowed in a private group.'; $lang->gitlab->apiError[2] = 'is too short (minimum is 8 characters)'; $lang->gitlab->apiError[3] = "can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"; +$lang->gitlab->apiError[4] = 'Branch already exists'; $lang->gitlab->errorLang[0] = '私有分组的项目,可见性级别不能设为内部。'; $lang->gitlab->errorLang[1] = '私有分组的项目,可见性级别不能设为公开。'; $lang->gitlab->errorLang[2] = '密码太短(最少8个字符)'; $lang->gitlab->errorLang[3] = "只能包含字母、数字、'.'-'和'.'。不能以'-'开头、以'.git'结尾或以'.atom'结尾。"; +$lang->gitlab->errorLang[4] = '分支名已存在。'; $lang->gitlab->project = new stdclass; $lang->gitlab->project->id = "项目ID"; @@ -171,3 +176,8 @@ $lang->gitlab->group->memberName = '账号'; $lang->gitlab->group->memberAccessLevel = '角色权限'; $lang->gitlab->group->memberExpiresAt = '过期时间'; $lang->gitlab->group->repeatError = "群组成员不能重复添加"; + +$lang->gitlab->branch = new stdclass(); +$lang->gitlab->branch->name = '分支名'; +$lang->gitlab->branch->from = '创建自'; +$lang->gitlab->branch->create = '创建'; diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 437a2a05ce..6ca9804d8d 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -896,6 +896,24 @@ class gitlabModel extends model return json_decode(commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE'))); } + /** + * Create a gitab user by api. + * + * @param int $gitlabID + * @param int $projectID + * @param object $branch + * @access public + * @return object + */ + public function apiCreateBranch($gitlabID, $projectID, $branch) + { + if(empty($branch->branch) or empty($branch->ref)) return false; + + $apiRoot = $this->getApiRoot($gitlabID); + $url = sprintf($apiRoot, "/projects/{$projectID}/repository/branches"); + return json_decode(commonModel::http($url, $branch)); + } + /** * Get single project by API. * @@ -2236,6 +2254,33 @@ class gitlabModel extends model return $this->apiErrorHandling($reponse); } + /** + * Create a gitlab branch. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return bool + */ + public function createBranch($gitlabID, $projectID) + { + $branch = fixer::input('post')->get(); + + if(empty($branch->branch)) dao::$errors['branch'][] = $this->lang->gitlab->branch->name . $this->lang->gitlab->emptyError; + if(empty($branch->ref)) dao::$errors['ref'][] = $this->lang->gitlab->branch->from . $this->lang->gitlab->emptyError; + if(dao::isError()) return false; + + $reponse = $this->apiCreateBranch($gitlabID, $projectID, $branch); + + if(!empty($reponse->name)) + { + $this->loadModel('action')->create('gitlabbranch', 0, 'created', '', $reponse->name); + return true; + } + + return $this->apiErrorHandling($reponse); + } + /** * Api error handling. * diff --git a/module/gitlab/view/createbranch.html.php b/module/gitlab/view/createbranch.html.php new file mode 100644 index 0000000000..391f3ff94c --- /dev/null +++ b/module/gitlab/view/createbranch.html.php @@ -0,0 +1,44 @@ + + * @package gitlab + * @version $Id$ + * @link https://www.zentao.net + */ +?> + +
    +
    +
    +
    +

    gitlab->createBranch;?>

    +
    +
    + + + + + + + + + + + + + + +
    gitlab->branch->name;?>gitlab->branch->name}'");?>
    gitlab->branch->from;?>
    + gitlab->branch->create);?> + session->gitlabBranchList ? $this->session->gitlabBranchList : inlink('browseBranch', "gitlibID=$gitlabID&projectID=$projectID");?> + goback, '', 'class="btn btn-wide"');?> +
    +
    +
    +
    +
    + diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index f4abbb41bb..552f0f9142 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -1245,6 +1245,7 @@ $lang->resource->gitlab->browseUser = 'browseUser'; $lang->resource->gitlab->createUser = 'createUser'; $lang->resource->gitlab->editUser = 'editUser'; $lang->resource->gitlab->deleteUser = 'deleteUser'; +$lang->resource->gitlab->createBranch = 'createBranch'; $lang->resource->gitlab->webhook = 'webhook'; $lang->resource->gitlab->createWebhook = 'createWebhook'; $lang->resource->gitlab->manageProjectMembers = 'manageProjectMembers'; diff --git a/module/repo/control.php b/module/repo/control.php index 2bc9dd1f34..78c3294bb2 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -357,6 +357,7 @@ class repo extends control session_start(); $this->session->set('revisionList', $this->app->getURI(true)); + $this->session->set('gitlabBranchList', $this->app->getURI(true)); session_write_close(); /* Get repo and synchronous commit. */ diff --git a/module/repo/view/browse.html.php b/module/repo/view/browse.html.php index 5a5d289fe0..cca1e145c7 100644 --- a/module/repo/view/browse.html.php +++ b/module/repo/view/browse.html.php @@ -59,6 +59,7 @@
    repo->notice->lastSyncTime . $cacheTime?> repo->createLink('browse', "repoID=$repoID&branchID=$base64BranchID&objectID=$objectID&path=" . $this->repo->encodePath($path) . "&revision=$revision&refresh=1"), " " . $lang->refresh, '', "class='btn btn-primary' data-app={$app->tab}");?> + SCM == 'Gitlab' and common::hasPriv('gitlab', 'createBranch')) echo html::a($this->createLink('gitlab', 'createBranch', "gitlabID={$repo->gitlab}&projectID={$repo->project}"), " " . $lang->gitlab->createBranch, '', "class='btn btn-primary'");?>
    From 1246c4f15d47789d756939e3cde606bda7a51735 Mon Sep 17 00:00:00 2001 From: zenggang Date: Tue, 7 Dec 2021 09:04:49 +0000 Subject: [PATCH 03/66] * Adjust code --- module/gitlab/view/manageprojectmembers.html.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/module/gitlab/view/manageprojectmembers.html.php b/module/gitlab/view/manageprojectmembers.html.php index 3d42a5d1ba..38a181948f 100644 --- a/module/gitlab/view/manageprojectmembers.html.php +++ b/module/gitlab/view/manageprojectmembers.html.php @@ -12,11 +12,9 @@ gitlab->group->memberName;?> - gitlab->group->memberAccessLevel;?> + gitlab->group->memberAccessLevel;?> gitlab->group->memberExpiresAt;?> actions;?> - - @@ -25,7 +23,7 @@ acl->users as $user):?> - '') + $this->lang->gitlab->accessLevels, isset($userAccessData[$user]) ? $userAccessData[$user]->access_level : '', "class='form-control chosen'");?> + '') + $this->lang->gitlab->accessLevels, isset($userAccessData[$user]) ? $userAccessData[$user]->access_level : '', "class='form-control levels chosen'");?> expires_at : '', "class='form-control form-date'");?> @@ -42,7 +40,7 @@ '') +$users, '', "class='form-control chosen'");?> - '') + $this->lang->gitlab->accessLevels, '', "class='form-control chosen'");?> + '') + $this->lang->gitlab->accessLevels, '', "class='form-control levels chosen'");?> ", '', "onclick='addItem(this)' class='btn btn-link'");?> @@ -73,7 +71,7 @@ - + - + + + @@ -23,7 +25,7 @@ acl->users as $user):?> - + - +