Skip to content

Commit c6ee0e6

Browse files
committed
Made filtered repository branching scalable
1 parent 0dc2d5f commit c6ee0e6

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

composer/repository.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ protected function get_include_files($prefix = '')
194194
protected function build_parents()
195195
{
196196
$this->build_parent_structure();
197-
$this->build_parent_structure(ext::TITANIA_REPOSITORY_MIN_PHPBB_BRANCH . '-');
197+
$branches = ext::get_filtered_repository_branches();
198+
foreach ($branches as $branch)
199+
{
200+
$this->build_parent_structure($branch . '-');
201+
}
198202
}
199203

200204
/**

config/routes/general.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ phpbb.titania.contribution.id:
6464
requirements:
6565
id: \d+
6666

67-
phpbb.titania.composer:
68-
path: /composer/{filename}.json
69-
defaults: { _controller: phpbb.titania.controller.composer:serve_file }
70-
7167
phpbb.titania.composer.40:
7268
path: /composer/40/
7369
defaults: { _controller: phpbb.titania.controller.composer:serve_file, filename: packages-40 }
7470

71+
phpbb.titania.composer:
72+
path: /composer/{filename}.json
73+
defaults: { _controller: phpbb.titania.controller.composer:serve_file }
74+
7575
phpbb.titania.category:
7676
path: /{category1}/{category2}/{category3}/{category4}
7777
defaults: { _controller: phpbb.titania.controller.index:display_category, category2: '', category3: '', category4: '' }

ext.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,14 @@ class ext extends \phpbb\extension\base
9595

9696
// Misc
9797
const TITANIA_CONFIG_PREFIX = 'titania_';
98-
const TITANIA_REPOSITORY_MIN_PHPBB_BRANCH = 40;
98+
99+
/**
100+
* Get filtered repository branch versions
101+
*
102+
* @return array Array of branch numbers to create filtered repositories for
103+
*/
104+
public static function get_filtered_repository_branches(): array
105+
{
106+
return [40];
107+
}
99108
}

manage/tool/composer/rebuild_repo.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@ public function run($from_file = false, $force = false, $progress = null)
197197

198198
$last_type = $last_contrib = '';
199199
$packages = array();
200-
$packages_phpbb4_only = array();
200+
$filtered_packages = array();
201+
$branches = ext::get_filtered_repository_branches();
202+
foreach ($branches as $branch)
203+
{
204+
$filtered_packages[$branch] = array();
205+
}
201206

202207
foreach ($batch as $contrib_id => $revisions)
203208
{
@@ -253,14 +258,17 @@ public function run($from_file = false, $force = false, $progress = null)
253258
$contrib_url
254259
);
255260

256-
if ($revision['phpbb_version_branch'] >= ext::TITANIA_REPOSITORY_MIN_PHPBB_BRANCH)
261+
foreach ($filtered_packages as $branch => $packages_data)
257262
{
258-
$packages_phpbb4_only = $this->repo->set_release(
259-
$packages_phpbb4_only,
260-
$revision['revision_composer_json'],
261-
$download_url,
262-
$contrib_url
263-
);
263+
if ($revision['phpbb_version_branch'] >= $branch)
264+
{
265+
$filtered_packages[$branch] = $this->repo->set_release(
266+
$filtered_packages[$branch],
267+
$revision['revision_composer_json'],
268+
$download_url,
269+
$contrib_url
270+
);
271+
}
264272
}
265273

266274
unset($batch[$contrib_id][$index]);
@@ -274,18 +282,24 @@ public function run($from_file = false, $force = false, $progress = null)
274282
if (($group_count % 50) === 0)
275283
{
276284
$this->dump_include($last_type, $group, $packages);
277-
$this->dump_include($last_type, $group, $packages_phpbb4_only, ext::TITANIA_REPOSITORY_MIN_PHPBB_BRANCH);
285+
foreach ($filtered_packages as $branch => $packages_data)
286+
{
287+
$this->dump_include($last_type, $group, $packages_data, $branch);
288+
$filtered_packages[$branch] = array();
289+
}
278290
$group_count = 0;
279291
$group++;
280292
$packages = array();
281-
$packages_phpbb4_only = array();
282293
}
283294
$group_count++;
284295
}
285296
if (!empty($packages))
286297
{
287298
$this->dump_include($last_type, $group, $packages);
288-
$this->dump_include($last_type, $group, $packages_phpbb4_only, ext::TITANIA_REPOSITORY_MIN_PHPBB_BRANCH);
299+
foreach ($filtered_packages as $branch => $packages_data)
300+
{
301+
$this->dump_include($last_type, $group, $packages_data, $branch);
302+
}
289303
}
290304

291305
$next_batch = $this->limit ? $this->start + $this->limit : $this->get_total();

0 commit comments

Comments
 (0)