diff --git a/module/api/v1/entries/gitlabwebhook.php b/module/api/v1/entries/gitlabwebhook.php index 5f97b824a1..a2739d0cc1 100644 --- a/module/api/v1/entries/gitlabwebhook.php +++ b/module/api/v1/entries/gitlabwebhook.php @@ -25,7 +25,7 @@ class gitlabWebhookEntry extends baseEntry $this->loadModel('repo'); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if(empty($repo)) return; $headers = getallheaders(); /* Fetch all HTTP request headers. */ diff --git a/module/ci/model.php b/module/ci/model.php index cd319310d8..91bb50efc2 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -28,7 +28,7 @@ class ciModel extends model if($this->session->repoID) { - $repo = $this->loadModel('repo')->getRepoByID($this->session->repoID); + $repo = $this->loadModel('repo')->getByID($this->session->repoID); if(!empty($repo) and !in_array(strtolower($repo->SCM), $this->config->repo->gitServiceList)) unset($this->lang->devops->menu->mr); $tab = $this->app->tab; diff --git a/module/design/control.php b/module/design/control.php index 6fb00e78f4..3ffe072c80 100755 --- a/module/design/control.php +++ b/module/design/control.php @@ -310,7 +310,7 @@ class design extends control $repos = $this->loadModel('repo')->getRepoPairs('project', $design->project); $repoID = $repoID ? $repoID : key($repos); - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); $revisions = $this->repo->getCommits($repo, '', 'HEAD', '', '', $begin, date('Y-m-d 23:59:59', strtotime($end))); if($_POST) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 0828467587..7d5bae38cf 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -1085,7 +1085,7 @@ class gitlab extends control } else { - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); $res = $this->gitlab->addPushWebhook($repo); if($res or is_array($res)) @@ -1115,7 +1115,7 @@ class gitlab extends control $accounts = array_filter($data->accounts); if(count($accounts) != count(array_unique($accounts))) return $this->send(array('result' => 'fail', 'message' => $this->lang->gitlab->group->repeatError)); - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); $users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted'); $bindedUsers = $this->dao->select('account,openID') ->from(TABLE_OAUTH) @@ -1217,7 +1217,7 @@ class gitlab extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => helper::createLink('repo', 'maintain'))); } - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); $users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted|noclosed'); $projectMembers = $this->gitlab->apiGetProjectMembers($repo->gitService, $repo->project); if(!is_array($projectMembers)) $projectMembers = array(); diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 1a0206f85f..06e665f03f 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -1290,6 +1290,7 @@ class gitlabModel extends model $hookList = $this->apiGetHooks($repo->gitService, $repo->project); foreach($hookList as $hook) { + if(empty($hook->url)) continue; if($hook->url == $url) return true; } return false; diff --git a/module/job/control.php b/module/job/control.php index 80c539975c..efb338984b 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -201,8 +201,8 @@ class job extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse', "repoID={$job->repo}"))); } - $repo = $this->loadModel('repo')->getRepoByID($job->repo); - $this->view->repo = $this->loadModel('repo')->getRepoByID($job->repo); + $repo = $this->loadModel('repo')->getByID($job->repo); + $this->view->repo = $this->loadModel('repo')->getByID($job->repo); if($repo->SCM == 'Gitlab') $this->view->refList = $this->loadModel('gitlab')->getReferenceOptions($repo->gitService, $repo->project); @@ -328,7 +328,7 @@ class job extends control $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->job = $job; $this->view->compile = $compile; - $this->view->repo = $this->loadModel('repo')->getRepoByID($job->repo); + $this->view->repo = $this->loadModel('repo')->getByID($job->repo); $this->view->jenkins = $this->loadModel('jenkins')->getById($job->server); $this->view->product = $this->loadModel('product')->getById($job->product); $this->display(); @@ -368,7 +368,7 @@ class job extends control */ public function ajaxGetProductByRepo($repoID) { - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); if(empty($repo)) return print(json_encode(array(""=>""))); $product = $repo->product; @@ -401,7 +401,7 @@ class job extends control */ public function ajaxGetRefList($repoID) { - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); if($repo->SCM == 'Gitlab') $refList = $this->loadModel('gitlab')->getReferenceOptions($repo->gitService, $repo->project); if($repo->SCM != 'Gitlab') $refList = $this->repo->getBranches($repo, true); $this->send(array('result' => 'success', 'refList' => $refList)); @@ -442,7 +442,7 @@ class job extends control */ public function ajaxGetRepoType($repoID) { - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); $this->send(array('result' => 'success', 'type' => strtolower($repo->SCM))); } diff --git a/module/job/model.php b/module/job/model.php index 847de0d18a..36223adf04 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -186,7 +186,7 @@ class jobModel extends model if(strtolower($job->engine) == 'gitlab') { - $repo = $this->loadModel('repo')->getRepoByID($job->repo); + $repo = $this->loadModel('repo')->getByID($job->repo); $project = zget($repo, 'project'); if(!empty($repo)) { @@ -312,7 +312,7 @@ class jobModel extends model if(strtolower($job->engine) == 'gitlab') { - $repo = $this->loadModel('repo')->getRepoByID($job->gitlabRepo); + $repo = $this->loadModel('repo')->getByID($job->gitlabRepo); $project = zget($repo, 'project'); if(!empty($repo)) { @@ -437,7 +437,7 @@ class jobModel extends model if($job->triggerType == 'tag') { - $repo = $this->loadModel('repo')->getRepoByID($job->repo); + $repo = $this->loadModel('repo')->getByID($job->repo); $lastTag = ''; if($repoType == 'Subversion') { diff --git a/module/mr/config.php b/module/mr/config.php index 4fe9c349d6..07b4eacc11 100644 --- a/module/mr/config.php +++ b/module/mr/config.php @@ -52,10 +52,11 @@ $config->mr->actionList['link']['icon'] = 'link'; $config->mr->actionList['link']['hint'] = $lang->mr->link; $config->mr->actionList['link']['url'] = helper::createLink('mr', 'link', "MRID={id}"); -$config->mr->actionList['delete']['icon'] = 'trash'; -$config->mr->actionList['delete']['hint'] = $lang->mr->delete; -$config->mr->actionList['delete']['url'] = helper::createLink('mr', 'delete', "MRID={id}"); -$config->mr->actionList['delete']['data-toggle'] = 'modal'; +$config->mr->actionList['delete']['icon'] = 'trash'; +$config->mr->actionList['delete']['hint'] = $lang->mr->delete; +$config->mr->actionList['delete']['url'] = helper::createLink('mr', 'delete', "MRID={id}&confirm=yes"); +$config->mr->actionList['delete']['data-toggle'] = 'modal'; +$config->mr->actionList['delete']['data-confirm'] = $lang->mr->confirmDelete; $config->mr->actionList['accept']['icon'] = 'flow'; $config->mr->actionList['accept']['text'] = $lang->mr->acceptMR; diff --git a/module/mr/control.php b/module/mr/control.php index 24c7babb17..95406bba1a 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -42,14 +42,19 @@ class mr extends control if($repoCount == 0) $this->locate($this->loadModel('repo')->createLink('create')); $repoID = $this->loadModel('repo')->saveState($repoID, $objectID); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if(!in_array(strtolower($repo->SCM), $this->config->mr->gitServiceList)) { $repoID = $this->dao->select('id')->from(TABLE_REPO)->where('deleted')->eq('0')->andWhere('SCM')->in(array('Gitlab', 'Gitea', 'Gogs'))->andWhere('synced')->eq(1)->orderBy('id')->fetch('id'); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); } $this->loadModel('ci')->setMenu($repo->id); + if($param == 'assignee' || $param == 'creator') + { + $mode = $param; + $param = $this->app->user->account; + } $filterProjects = empty($repo->serviceProject) ? array() : array($repo->serviceHost => array($repo->serviceProject => $repo->serviceProject)); $MRList = $this->mr->getList($mode, $param, $orderBy, $pager, $filterProjects, $repoID); if($repo->SCM == 'Gitlab') @@ -131,7 +136,7 @@ class mr extends control } $repoID = $this->loadModel('repo')->saveState(0); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $this->loadModel('gitlab'); $this->loadModel('gitea'); @@ -468,7 +473,7 @@ class mr extends control } } - $this->view->repo = $this->loadModel('repo')->getRepoByID($MR->repoID); + $this->view->repo = $this->loadModel('repo')->getByID($MR->repoID); $this->view->repoID = $MR->repoID; $this->view->diffs = $diffs; $this->view->encoding = $encoding; diff --git a/module/mr/js/create.ui.js b/module/mr/js/create.ui.js index 046431d390..b67f6d7ea9 100644 --- a/module/mr/js/create.ui.js +++ b/module/mr/js/create.ui.js @@ -127,7 +127,7 @@ function onHostChange() if(repo.project) { $('#sourceProject').val(repo.project); - onSourceProjectChange(); + $('#sourceProject').trigger('change'); } }); } diff --git a/module/mr/lang/zh-cn.php b/module/mr/lang/zh-cn.php index a6ae9db172..77389766d0 100644 --- a/module/mr/lang/zh-cn.php +++ b/module/mr/lang/zh-cn.php @@ -66,7 +66,7 @@ $lang->mr->approvalResultList['reject'] = '拒绝'; $lang->mr->needApproved = '需要通过评审才能合并'; $lang->mr->needCI = '需要通过构建才能合并'; $lang->mr->removeSourceBranch = '合并后删除源分支'; -$lang->mr->squash = '合并提交'; +$lang->mr->squash = '合并提交记录'; $lang->mr->repeatedOperation = '请勿重复操作'; diff --git a/module/mr/model.php b/module/mr/model.php index 919e30cc9b..30b02853d3 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -1141,7 +1141,7 @@ class mrModel extends model $host = $this->loadModel('pipeline')->getByID($MR->hostID); $scm = $host->type; - $repo = $this->loadModel('repo')->getRepoByID($MR->repoID); + $repo = $this->loadModel('repo')->getByID($MR->repoID); $repo->gitService = $host->id; $repo->project = $MR->targetProject; $repo->password = $host->token; @@ -1796,7 +1796,7 @@ class mrModel extends model $host = $this->loadModel('pipeline')->getByID($MR->hostID); if($host->type == 'gogs') { - $repo = $this->loadModel('repo')->getRepoByID($MR->repoID); + $repo = $this->loadModel('repo')->getByID($MR->repoID); $scm = $this->app->loadClass('scm'); $scm->setEngine($repo); return $scm->getMRCommits($MR->sourceBranch, $MR->targetBranch); @@ -2104,8 +2104,8 @@ class mrModel extends model public static function isClickable(object $MR, string $action): bool { if($action == 'edit' and !$MR->synced) return false; - if($action == 'edit') return $MR->canEdit; - if($action == 'delete') return $MR->canDelete; + if($action == 'edit') return $MR->canEdit != 'disabled'; + if($action == 'delete') return $MR->canDelete != 'disabled'; return true; } diff --git a/module/mr/ui/browse.html.php b/module/mr/ui/browse.html.php index 9b2f79b5dc..839e058a27 100644 --- a/module/mr/ui/browse.html.php +++ b/module/mr/ui/browse.html.php @@ -10,8 +10,24 @@ declare(strict_types=1); */ namespace zin; +dropmenu(set::module('repo')); + foreach($MRList as $MR) { + $MR->canDelete = ($app->user->admin or (isset($openIDList[$MR->hostID]) and isset($projects[$MR->hostID][$MR->sourceProject]->owner->id) and $projects[$MR->hostID][$MR->sourceProject]->owner->id == $openIDList[$MR->hostID])) ? '' : 'disabled'; + if($repo->SCM == 'Gitlab') + { + $MR->canEdit = (isset($projects[$MR->hostID][$MR->sourceProject]->isDeveloper) and $projects[$MR->hostID][$MR->sourceProject]->isDeveloper == true) ? '' : 'disabled'; + } + elseif($repo->SCM == 'Gitea') + { + $MR->canEdit = (isset($projects[$MR->hostID][$MR->sourceProject]->allow_merge_commits) and $projects[$MR->hostID][$MR->sourceProject]->allow_merge_commits == true) ? '' : 'disabled'; + } + elseif($repo->SCM == 'Gogs') + { + $MR->canEdit = (isset($projects[$MR->hostID][$MR->sourceProject]->permissions->push) and $projects[$MR->hostID][$MR->sourceProject]->permissions->push) ? '' : 'disabled'; + } + if($repo->SCM == 'Gitlab') { $MR->sourceProject = isset($projects[$MR->hostID][$MR->sourceProject]) ? $projects[$MR->hostID][$MR->sourceProject]->name_with_namespace . ':' . $MR->sourceBranch : $MR->sourceProject . ':' . $MR->sourceBranch; @@ -33,27 +49,13 @@ foreach($MRList as $MR) { $MR->approvalStatus = empty($MR->approvalStatus) ? $lang->mr->approvalStatusList['notReviewed'] : $lang->mr->approvalStatusList[$MR->approvalStatus]; } - - $MR->canDelete = ($app->user->admin or (isset($openIDList[$MR->hostID]) and isset($projects[$MR->hostID][$MR->sourceProject]->owner->id) and $projects[$MR->hostID][$MR->sourceProject]->owner->id == $openIDList[$MR->hostID])) ? '' : 'disabled'; - if($repo->SCM == 'Gitlab') - { - $MR->canEdit = (isset($projects[$MR->hostID][$MR->sourceProject]->isDeveloper) and $projects[$MR->hostID][$MR->sourceProject]->isDeveloper == true) ? '' : 'disabled'; - } - elseif($repo->SCM == 'Gitea') - { - $MR->canEdit = (isset($projects[$MR->hostID][$MR->sourceProject]->allow_merge_commits) and $projects[$MR->hostID][$MR->sourceProject]->allow_merge_commits == true) ? '' : 'disabled'; - } - elseif($repo->SCM == 'Gogs') - { - $MR->canEdit = (isset($projects[$MR->hostID][$MR->sourceProject]->permissions->push) and $projects[$MR->hostID][$MR->sourceProject]->permissions->push) ? '' : 'disabled'; - } } $MRs = initTableData($MRList, $config->mr->dtable->fieldList, $this->mr); featureBar ( - set::current($param), + set::current($mode != 'status' ? $mode : $param), set::linkParams("repoID={$repoID}&mode=status¶m={key}"), ); diff --git a/module/mr/ui/create.html.php b/module/mr/ui/create.html.php index 19fca9f6d9..8aace0d7e3 100644 --- a/module/mr/ui/create.html.php +++ b/module/mr/ui/create.html.php @@ -93,7 +93,6 @@ formPanel ), formGroup ( - set::required(true), set::name('removeSourceBranch'), set::label($lang->mr->removeSourceBranch), set::control('checkbox'), diff --git a/module/mr/ui/edit.html.php b/module/mr/ui/edit.html.php index 44c0e6f3dc..1874cfe288 100644 --- a/module/mr/ui/edit.html.php +++ b/module/mr/ui/edit.html.php @@ -37,6 +37,7 @@ formPanel ( formGroup ( + set::width('2/3'), set::required(true), set::label($lang->mr->targetProject), inputGroup diff --git a/module/repo/config/form.php b/module/repo/config/form.php index f2d15fc0af..abda3991f3 100644 --- a/module/repo/config/form.php +++ b/module/repo/config/form.php @@ -8,7 +8,7 @@ $config->repo->form->create['product'] = array('required' => true, 'type $config->repo->form->create['projects'] = array('required' => false, 'type' => 'array', 'default' => array()); $config->repo->form->create['SCM'] = array('required' => true, 'type' => 'string', 'filter' => 'trim'); $config->repo->form->create['serviceHost'] = array('required' => true, 'type' => 'int'); -$config->repo->form->create['serviceProject'] = array('required' => false, 'type' => 'int', 'default' => 0); +$config->repo->form->create['serviceProject'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->repo->form->create['name'] = array('required' => true, 'type' => 'string', 'filter' => 'trim'); $config->repo->form->create['path'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->repo->form->create['encoding'] = array('required' => true, 'type' => 'string'); diff --git a/module/repo/control.php b/module/repo/control.php index f39bca5bba..604b5f7a33 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -146,7 +146,7 @@ class repo extends control if($this->post->SCM == 'Gitlab') { /* Add webhook. */ - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $this->loadModel('gitlab')->addPushWebhook($repo); $this->gitlab->updateCodePath($repo->serviceHost, $repo->serviceProject, $repo->id); } @@ -173,13 +173,13 @@ class repo extends control { $this->commonAction($repoID, $objectID); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if($_POST) { $noNeedSync = $this->repo->update($repoID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $newRepo = $this->repo->getRepoByID($repoID); + $newRepo = $this->repo->getByID($repoID); $actionID = $this->loadModel('action')->create('repo', $repoID, 'edited'); $changes = common::createChanges($repo, $newRepo); $this->action->logHistory($actionID, $changes); @@ -274,7 +274,7 @@ class repo extends control public function ajaxGetDiffEditorContent($repoID, $objectID = 0, $entry = '', $oldRevision = '', $newRevision = '', $showBug = 'false', $encoding = '') { $file = $entry; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $entry = urldecode($this->repo->decodePath($entry)); $revision = str_replace('*', '-', $oldRevision); $nRevision = str_replace('*', '-', $newRevision); @@ -321,7 +321,7 @@ class repo extends control public function ajaxGetEditorContent($repoID, $objectID = 0, $entry = '', $revision = 'HEAD', $showBug = 'false', $encoding = '') { $file = $entry; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $entry = urldecode($this->repo->decodePath($entry)); $revision = str_replace('*', '-', $revision); @@ -384,7 +384,7 @@ class repo extends control public function monaco($repoID, $objectID = 0, $entry = '', $revision = 'HEAD', $showBug = 'false', $encoding = '') { $file = $entry; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $entry = $this->repo->decodePath($entry); $entry = urldecode($entry); $pathInfo = pathinfo($entry); @@ -432,7 +432,7 @@ class repo extends control } $this->commonAction($repoID, $objectID); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if($browser['name'] != 'ie') return print($this->fetch('repo', 'monaco', "repoID=$repoID&objectID=$objectID&entry=$entry&revision=$revision&showBug=$showBug&encoding=$encoding")); if($_POST) @@ -547,7 +547,7 @@ class repo extends control session_write_close(); /* Get repo and synchronous commit. */ - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if($repo->SCM == 'Git' and !is_dir($repo->path)) { $error = sprintf($this->lang->repo->error->notFound, $repo->name, $repo->path); @@ -683,7 +683,7 @@ class repo extends control $this->repo->setBackSession('log', true); if($repoID == 0) $repoID = $this->session->repoID; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $file = $entry; $entry = $this->repo->decodePath($entry); @@ -737,7 +737,7 @@ class repo extends control public function revision($repoID, $objectID = 0, $revision = '') { if($repoID == 0) $repoID = $this->session->repoID; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $this->scm->setEngine($repo); $log = $this->scm->log('', $revision, $revision); @@ -784,7 +784,7 @@ class repo extends control if($this->get->repoPath) $entry = $this->get->repoPath; if($repoID == 0) $repoID = $this->session->repoID; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $file = $entry; $entry = $this->repo->decodePath($entry); @@ -838,7 +838,7 @@ class repo extends control if($this->get->repoPath) $entry = $this->get->repoPath; $file = $entry; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $entry = $this->repo->decodePath($entry); if($repo->SCM == 'Git' and !is_dir($repo->path)) @@ -957,7 +957,7 @@ class repo extends control { if($this->get->repoPath) $path = $this->get->repoPath; $entry = $this->repo->decodePath($path); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if($isBranchOrTag) { @@ -1066,7 +1066,7 @@ class repo extends control $this->loadModel('story'); $this->app->loadLang('productplan'); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $product = $this->loadModel('product')->getById($repo->product); $modules = $this->loadModel('tree')->getOptionMenu($repo->product, 'story'); @@ -1154,7 +1154,7 @@ class repo extends control $this->app->loadLang('productplan'); $queryID = ($browseType == 'bysearch') ? (int)$param : 0; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $product = $this->loadModel('product')->getById($repo->product); $modules = $this->loadModel('tree')->getOptionMenu($product->id, 'bug'); @@ -1245,7 +1245,7 @@ class repo extends control $browseType = strtolower($browseType); $queryID = ($browseType == 'bysearch') ? (int)$param : 0; - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $product = $this->loadModel('product')->getById($repo->product); $modules = $this->loadModel('tree')->getOptionMenu($product->id, 'task'); @@ -1377,7 +1377,7 @@ class repo extends control public function ajaxSyncCommit($repoID = 0, $type = 'batch') { set_time_limit(0); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if(empty($repo)) return; if($repo->synced) return print('finish'); @@ -1510,7 +1510,7 @@ class repo extends control public function ajaxSyncBranchCommit($repoID = 0, $branch = '') { set_time_limit(0); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if(empty($repo)) return; if(!in_array($repo->SCM, $this->config->repo->gitTypeList)) return print('finish'); if($branch) $branch = base64_decode(helper::safe64Decode($branch)); @@ -1567,11 +1567,11 @@ class repo extends control $this->app->loadClass('pager', true); $pager = new pager($recTotal, $recPerPage, $pageID); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $path = $this->repo->decodePath($path); $revisions = $this->repo->getCommits($repo, $path, 'HEAD', $type, $pager); - $this->view->repo = $this->repo->getRepoByID($repoID); + $this->view->repo = $this->repo->getByID($repoID); $this->view->revisions = $revisions; $this->view->pager = $pager; $this->view->repoID = $repoID; @@ -1591,7 +1591,7 @@ class repo extends control */ public function ajaxGetSVNDirs($repoID, $path = '') { - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); if($repo->SCM != 'Subversion') return print(json_encode(array())); $path = $this->repo->decodePath($path); @@ -1826,7 +1826,7 @@ class repo extends control */ public function ajaxGetBranchDropMenu($repoID, $branchID, $objectID) { - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $branches = $this->repo->getBranches($repo); if($branchID) $branchID = base64_decode($branchID); @@ -1917,7 +1917,7 @@ class repo extends control mkdir($savePath, 0777, true); } - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $this->scm = $this->app->loadClass('scm'); $this->scm->setEngine($repo); $url = $this->scm->getDownloadUrl($branch, $savePath); @@ -1951,7 +1951,7 @@ class repo extends control public function ajaxGetFileTree($repoID, $branch = '') { $branch = base64_decode($branch); - $repo = $this->repo->getRepoByID($repoID); + $repo = $this->repo->getByID($repoID); $files = $this->repo->getFileTree($repo, $branch); return print($files); } @@ -2010,7 +2010,7 @@ class repo extends control public function ajaxGetCommitInfo() { $line = $this->post->line; - $repo = $this->repo->getRepoByID($this->post->repoID); + $repo = $this->repo->getByID($this->post->repoID); $entry = $this->repo->decodePath($this->post->entry); $revision = $this->post->revision; $returnType = $this->post->returnType ? $this->post->returnType : 'view'; diff --git a/module/repo/model.php b/module/repo/model.php index f1868bb4a5..d8c2a7d6fc 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -44,7 +44,7 @@ class repoModel extends model /* Check the privilege. */ if($repoID) { - $repo = $this->getRepoByID($repoID); + $repo = $this->getByID($repoID); if(empty($repo)) { echo(js::alert($this->lang->repo->error->noFound)); @@ -81,7 +81,7 @@ class repoModel extends model if(!in_array($currentModule, $this->config->repo->switcherModuleList)) return ''; if($currentModule == 'repo' and !in_array($currentMethod, $this->config->repo->switcherMethodList)) return ''; - $currentRepo = $this->getRepoByID($repoID); + $currentRepo = $this->getByID($repoID); $currentRepoName = $currentRepo->name; if($this->app->viewType == 'mhtml' and $repoID) @@ -260,7 +260,7 @@ class repoModel extends model if($repo->SCM == 'Gitlab') { /* Add webhook. */ - $repo = $this->getRepoByID($repoID); + $repo = $this->getByID($repoID); $this->loadModel('gitlab')->addPushWebhook($repo); } @@ -279,7 +279,7 @@ class repoModel extends model */ public function update($id) { - $repo = $this->getRepoByID($id); + $repo = $this->getByID($id); if($repo->client != $this->post->client and !$this->checkClient()) return false; if(!$this->checkConnection()) return false; @@ -331,7 +331,7 @@ class repoModel extends model $this->rmClientVersionFile(); - if($data->SCM == 'Gitlab') $data->path = $this->getRepoByID($id)->path; + if($data->SCM == 'Gitlab') $data->path = $this->getByID($id)->path; if($repo->path != $data->path) { @@ -529,7 +529,7 @@ class repoModel extends model * @access public * @return object */ - public function getRepoByID($repoID) + public function getByID($repoID) { $repo = $this->dao->select('*')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch(); if(!$repo) return false; @@ -842,7 +842,7 @@ class repoModel extends model ->fetch(); if(empty($lastComment)) return null; - $repo = $this->getRepoByID($repoID); + $repo = $this->getByID($repoID); if($repo->SCM == 'Git' and $lastComment->commit != $count) { $this->fixCommit($repo->id); @@ -940,7 +940,7 @@ class repoModel extends model */ public function getProductsByRepo($repoID) { - $repo = $this->getRepoByID($repoID); + $repo = $this->getByID($repoID); if(empty($repo)) return array(); return $this->dao->select('id,name')->from(TABLE_PRODUCT) @@ -1535,6 +1535,7 @@ class repoModel extends model { $cmd = 'git clone --progress -v "' . $project->tokenCloneUrl . '" "' . $path . '" > "' . $this->app->getTmpRoot() . "log/clone.progress.$module.{$this->post->name}.log\" 2>&1 &"; if(PHP_OS == 'WINNT') $cmd = "start /b $cmd"; + var_dump($cmd);exit; exec($cmd); } $_POST['path'] = $path; @@ -2667,7 +2668,7 @@ class repoModel extends model $output = new stdClass(); $scm = $this->app->loadClass('scm'); - $repo = $this->getRepoByID($repoID); + $repo = $this->getByID($repoID); if(!$repo) return $output; $scm->setEngine($repo); @@ -2802,7 +2803,7 @@ class repoModel extends model public function insertDeleteRecord($repoID) { set_time_limit(0); - $repo = $this->loadModel('repo')->getRepoByID($repoID); + $repo = $this->loadModel('repo')->getByID($repoID); if(empty($repo)) return false; $scm = $this->app->loadClass('scm'); @@ -2908,7 +2909,7 @@ class repoModel extends model */ public function updateCommit($repoID, $objectID = 0, $branchID = 0) { - $repo = $this->getRepoByID($repoID); + $repo = $this->getByID($repoID); /* Update code commit history. */ $commentGroup = $this->loadModel('job')->getTriggerGroup('commit', array($repoID)); diff --git a/module/repo/ui/ajaxgetdropmenu.html.php b/module/repo/ui/ajaxgetdropmenu.html.php new file mode 100644 index 0000000000..78a3a7eed5 --- /dev/null +++ b/module/repo/ui/ajaxgetdropmenu.html.php @@ -0,0 +1,21 @@ + + * @package repo + * @link https://www.zentao.net + */ +namespace zin; + +$data = array('repo'); + +$json = array(); +$json['data'] = $data; +$json['searchHint'] = $lang->searchAB; +$json['link'] = sprintf($link, '{id}'); +$json['itemType'] = 'product'; + +renderJson($json); diff --git a/module/repo/ui/browse.html.php b/module/repo/ui/browse.html.php index f87faac425..d5c58f2bfc 100644 --- a/module/repo/ui/browse.html.php +++ b/module/repo/ui/browse.html.php @@ -12,6 +12,8 @@ declare(strict_types=1); namespace zin; +dropMenu(set::module('repo')); + /* Prepare repo select data. */ $menus = array(); $selected = ''; diff --git a/module/repo/zen.php b/module/repo/zen.php index 46ec1cdd1f..be79631827 100644 --- a/module/repo/zen.php +++ b/module/repo/zen.php @@ -33,6 +33,7 @@ class repoZen extends repo ->setIf($isPipelineServer, 'prefix', '') ->setIf($this->post->SCM == 'Git', 'account', '') ->setIf($this->post->SCM == 'Git', 'password', '') + ->setIf(in_array($this->post->SCM, array('Gitea', 'Gogs')), 'path', $_POST['path']) ->setIf($this->post->acl != '', 'acl', json_encode($this->post->acl)) ->setIf($this->post->encrypt == 'base64', 'password', base64_encode($this->post->password)) ->skipSpecial('path,client,account,password')