Repository navigation
fix(builds): reuse the cloned branch when pushing a template into a repository - #14549
Conversation
|
Review complete. 🟡 1 medium 📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Failed build leaves stale // src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
427 } catch (\Throwable $th) {The build working tree is keyed by deployment id ( The change addresses a template-deployment failure for Gitea-backed functions and pins it with an e2e test covering both clone paths.
Reviewed commit: a6c05ce |
🟢 Tier S · Ready to merge
The Builds worker now reuses an already checked-out branch or creates it from a detached commit before committing and pushing template files. The VCSGitea e2e suite covers both clone modes, and its CI lane now includes the worker path.
📂 Walkthrough · 3
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
Deploying a template into a connected repository fails with
Unable to push code repository: fatal: a branch named 'main' already exists.The Builds worker clones the repository, merges the template in, then runs
git checkout -b <providerBranch>before committing and pushing. When the deployment has no commit hash, the clone is a branch clone, and the shared clone command already leaves that branch checked out (git pull+git checkout <branch>, orgit checkout -b <branch>when the remote branch is missing). The secondcheckout -bthen fails. This happens on every tag-type template (redeployVcsFunction/redeployVcsSiteset onlyproviderBranchfor tags), and on branch-type templates when the head commit lookup fails.The worker now runs
git checkout -B <branch>. On a branch clone the branch is already at HEAD, so this is a no-op. On a commit clone (detached HEAD) it creates the branch at that commit, as-bdid. Commit and push are unchanged.#14137 (the earlier CLOUD-3R60 fix) is in cloud 1.50.182 (server-ce
939fa5e8cc). It fixed wildcard tag resolution when cloning the template. That let tag-type template deployments get as far as the push, where they hit this bug.Fixes CLOUD-3R7M
Fixes CLOUD-3R60
Test Plan
VCSGiteaConsoleClientTest::testCreateTemplateDeploymentIntoRepositorydeploys the starter template into a Gitea repository for both clone types: atagtemplate (branch clone ofmain) and abranchtemplate (commit clone, detached HEAD). It asserts that the build is ready, the template commit is the head ofmain, the deployment'sproviderCommitHashmatches it, and the template files are in the repository.Unable to push code repository: fatal: a branch named 'main' already exists. With the fix, both cases pass, and the fullVCSGiteasuite passes (26 tests).VCSGitealane in.github/ci/e2e.jsonnow also claimsFunctions/Workers/Builds.php, so it runs on changes to this worker.Checklist
Closes #14550