From 3dc7a2111b1755c7e08a0824a3a6369c2d6261fb Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 17 Aug 2021 17:44:58 +0800 Subject: [PATCH 1/4] + Get project branches. --- module/gitlab/control.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 7c8d75630e..0193f67792 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -349,4 +349,25 @@ class gitlab extends control } return $this->send($options); } + + /** + * AJAX: Get project branches. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return object + */ + public function ajaxGetProjectBranches($gitlabID, $projectID) + { + if(!$gitlabID or !$projectID) return $this->send(array('message' => array())); + + $branches = $this->gitlab->apiGetBranches($gitlabID, $projectID); + $options = ""; + foreach($branches as $index =>$branch) + { + $options .= ""; + } + return $this->send($options); + } } From 5728c38e66ba84c4243449cd731ba10461e17bc4 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 17 Aug 2021 17:49:47 +0800 Subject: [PATCH 2/4] * Remove and correct useless statements. --- module/gitlab/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index e80bbf41e2..8b49ceda0c 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -277,8 +277,8 @@ class gitlabModel extends model public function getRefOptions($gitlabID, $projectID) { $refList = array(); - $branches = $this->loadModel('gitlab')->apiGetBranches($gitlabID, $projectID); - $tags = $this->loadModel('gitlab')->apiGetTags($gitlabID, $projectID); + $branches = $this->apiGetBranches($gitlabID, $projectID); + $tags = $this->apiGetTags($gitlabID, $projectID); foreach($branches as $branch) $refList[] = "Branch::" . $branch->name; foreach($tags as $tag) $refList[] = "Tag::" . $tag->name; return $refList; From d9683594db29515294c4ab2730f3022c81101ae4 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 17 Aug 2021 17:52:05 +0800 Subject: [PATCH 3/4] + Get forked projects. --- module/mr/control.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/module/mr/control.php b/module/mr/control.php index 18b1bca7c9..100d6928df 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -76,5 +76,29 @@ class mr extends control public function update() { } + + /** + * AJAX: Get forked projects. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return void + */ + public function ajaxGetForkedProjects($gitlabID, $projectID) + { + $projects = $this->mr->apiGetForks($gitlabID, $projectID); + + if(!$projects) return $this->send(array('message' => array())); + $projectIdList = $projectIdList ? explode(',', $projectIdList) : null; + $options = ""; + foreach($projects as $project) + { + if(!empty($projectIdList) and $project and !in_array($project->id, $projectIdList)) continue; + $options .= ""; + } + + return $this->send($options); + } } From 549ea9bbde37743868293fdff517707939a7320c Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 17 Aug 2021 17:52:55 +0800 Subject: [PATCH 4/4] * Create MR(staging). --- module/mr/js/create.js | 11 ++++++++++- module/mr/view/create.html.php | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/module/mr/js/create.js b/module/mr/js/create.js index dc117c16f7..3ab3aa2b2f 100644 --- a/module/mr/js/create.js +++ b/module/mr/js/create.js @@ -3,8 +3,8 @@ $(function() $('#gitlabID').change(function() { host = $('#gitlabID').val(); - url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host); if(host == '') return false; + url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host); $.get(url, function(response) { @@ -17,6 +17,15 @@ $(function() { $option = $(this).find('option:selected'); $('#name').val($option.data('name')); + project = $('#sourceProject').val(); + url = createLink('gitlab', 'ajaxgetprojectbranches', "gitlabID=" + host + "&projectID=" + project); + $.get(url, function(response) + { + $('#sourceBranch').html('').append(response); + $('#sourceBranch').chosen().trigger("chosen:updated");; + }); + + $('#targetProject').chosen().trigger("chosen:updated");; }); }); diff --git a/module/mr/view/create.html.php b/module/mr/view/create.html.php index 1e4323582a..d05a6824db 100644 --- a/module/mr/view/create.html.php +++ b/module/mr/view/create.html.php @@ -22,7 +22,6 @@ mr->sourceProject;?>
- mr->sourceBranch ?>