Resolve template version ranges via vcs 4.4.0 listTags

Templates can pin a version range (e.g. providerVersion "0.3.*"); codeload only
accepts a concrete ref, so the jobs template path 404'd on ranges while the
executor resolved them with `git ls-remote --tags | tail -1`. Bump utopia-php/vcs
to 4.4.0 and use listTags(owner, repo, glob) to resolve the range to the highest
matching tag before building the codeload URL. Guarded so a lookup failure
degrades to the raw ref rather than failing the request.

Known upstream gap: listTags interpolates the access token straight into the
Authorization header, so it fatals on an uninitialized adapter — and public
templates have no installation/token. GitHub's matching-refs endpoint serves
public repos unauthenticated (verified 200), but an empty `Bearer ` is 401, so
the adapter must OMIT the header when there is no token. Needs a vcs follow-up;
until then range resolution no-ops for public templates (guarded).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
loks0nandClaude Opus 4.8 committed 2026-07-10 16:46:38 +01:00
1 parent 3772b3eb6f
commit dc6fdc04f6
2 files changed
+15 -2

No files matched your search

+1 -1
View File
@@ -94,7 +94,7 @@
"utopia-php/storage": "2.*",
"utopia-php/system": "0.10.*",
"utopia-php/telemetry": "^0.4",
"utopia-php/vcs": "^4.3.0",
"utopia-php/vcs": "^4.4.0",
"utopia-php/websocket": "1.0.*",
"matomo/device-detector": "6.4.*",
"dragonmantank/cron-expression": "3.4.*",
@@ -207,10 +207,23 @@ class Create extends Base
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform, $authorization);
if ($useJobs) {
// Templates can pin a version range (e.g. "0.3.*"); codeload only
// takes a concrete ref, so resolve the range to the highest matching
// tag (mirrors the executor's `git ls-remote --tags | tail -1`).
$ref = $reference;
if ($type === GitHub::CLONE_TYPE_TAG && \str_contains($reference, '*')) {
try {
$tags = $github->listTags($owner, $repository, $reference);
$ref = \end($tags) ?: $reference;
} catch (\Throwable) {
// Fall back to the raw reference; the build surfaces a bad ref.
}
}
// Public template: pull the source straight from GitHub's codeload
// tarball; unarchive strips the "{repo}-{ref}/" wrapper + the rootDirectory.
$source = [
'url' => "https://codeload.github.com/{$owner}/{$repository}/tar.gz/{$reference}",
'url' => "https://codeload.github.com/{$owner}/{$repository}/tar.gz/{$ref}",
'subdir' => $rootDirectory,
];
$jobs->create(...Job::build($project, $function, $deployment, $platform, $source));