Repository navigation
refactor: build VCS clone, git and build job commands with Utopia\Command - #14022
Conversation
🔵 Tier A · Mergeable after minor fixes
Moves VCS cloning and Git helpers, DiffCheck commands, and deployment build-job commands onto Utopia\Command. Consolidates clone generation across providers, adds ref validation and local clone tests, and changes tag checkout to fetch the named tag directly.
Fix with agent prompt### Issue 1
src/Appwrite/Deployment/Deployments.php:472-477
**Cover the deployment job command changes with regression tests**
The existing `tests/unit/Deployment/DeploymentsTest.php` exercises payload generation, but no test covers the newly omitted empty build argument or the rewritten best-effort staging command. Please add shell-level regression coverage verifying that empty builds still succeed, nonempty build commands arrive unchanged as one argument, and staging failure does not prevent the build from running.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 13
Reviewed |
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
generateCloneCommand() now returns a Command instead of a string. The five near-identical generators share Git::cloneCommand(), which passes every value as its own argument: cd becomes git -C, echo becomes printf, and the branch fallback is a constant sh -c script that reads its values from positional parameters. Refs starting with a dash are rejected so they cannot reach git as options. This also fixes the Gitea tag clone, which interpolated the tag name unquoted, and replaces GitHub's and Origin's ls-remote | awk tag lookup with a direct refs/tags fetch. Origin's and Gogs' git helpers run through Console::execute with Command, and Gogs no longer echoes the token-carrying clone URL in its error message. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
The staging step stays best effort: a failed copy still lets build.sh run, as the previous ';' did. An empty build command is left out, which build.sh treats the same as an empty argument. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
…haviour Review follow-up. DiffCheck gets diffCommand() and the Git adapter a shared git() in place of closures, and Gogs and Origin use git() too. The clone tests now run the shared clone command against a local repository through a LocalGit test adapter, asserting which files are checked out and that a root directory full of tar options and shell syntax is checked out as a literal directory without running anything. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
Applies Rector's NewMethodCallWithoutParenthesesRector, which the vcs package's PHP set enforces and CI checks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
A tag reaches git as refs/tags/<name>, so a leading dash cannot turn it into an option; only branch and commit values are rejected now, as tag clones accepted such names before. CloneCommandTest restores whatever GIT_CONFIG_GLOBAL held before it ran instead of unsetting it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu Co-Authored-By: Torsten Dittmann <[email protected]>
3bdcfdf to
b15116d
Compare
Main moved by 20 commits, which left the PR conflicting, so GitHub ran no CI on f4351e9. The commits bring: - the email-password session duration parameter (#14004); - resolved-address reuse for outbound requests (#14028); - VCS and build commands through Utopia\Command (#14022); - the full first chunk in the resume ownership test (#14026). That is the same change as the branch's e24bef4, so it merged cleanly. The one conflict was the import block of src/Appwrite/Deployment/Deployments.php. The branch had added ClientExceptionInterface and main had added Utopia\Command, so both stay, in alphabetical order. Main changed neither the root composer.json nor composer.lock, and none of its changes touch the database 8 API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Template versions such as 0.1.* are not refspecs. PR appwrite#14022 fetches refs/tags/<version> directly, so those clones fail. Resolve a glob to the last tag git ls-remote lists for it, the same tag the old GitHub and Origin lookup selected, and keep exact tag names on the direct fetch. Co-authored-by: Chirag Aggarwal <[email protected]>
What does this PR do?
Follow-up to #13616. That PR moved the builds worker's local commands onto
Utopia\Commandbut left the git clone commands as strings, becauseutopia-php/vcsreturned them as strings. This PR converts those, plus the other shell strings on request and worker paths.packages/vcsgenerateCloneCommand()now returns aCommandinstead of a string.Builds.phpneeds no change becauseConsole::execute()already accepts aCommand.Git::cloneCommand(). Each adapter keeps only its clone-URL logic.cdbecomesgit -C, through a sharedGit::git($directory)that Origin and Gogs use too.echo >> sparse-checkoutbecomesprintf '%s\n'.sh -cscript that reads the directory and branch from positional parameters.-is rejected, so it can't reach git as an option. Tags are exempt, because they travel asrefs/tags/<name>.{$version}into the command without quoting.ls-remote | awk. They now fetchrefs/tags/<name>directly, as Bitbucket and GitLab already did.OriginandGogsgit helpers (createFile, createBranch, createTag) now run throughConsole::execute()withCommand.Gogserror messages no longer include the command, which contained the clone URL and its access token.utopia-php/console: ^0.2requirement.generateCloneCommand()breaks the public API of the mirroredutopia-php/vcspackage, so it needs a new version when released.packages/agentsDiffChecknow builds itscp,git clone,checkoutandgit diff | headcommands withCommand, the diff through adiffCommand()method. Adds autopia-php/console: ^0.2requirement.src/Appwrite/Deployment/Deployments.phpCommandand sent to the orchestrator as a string, as before.;, now|| true, so a failed copy still letsbuild.shrun.'', becauseCommandrefuses empty arguments. open-runtimes'build.shrunsbash -c "$1"withoutset -u, so both cases behave the same.Not changed: the installer and the
SDKs/Specstasks. These are operator and developer tooling that don't take API input.Test Plan
CloneCommandTestruns the shared clone command against a local bare repository, through aLocalGittest adapter, and checks what lands on disk:'',.,./,/,docs,./docs/, nested,0) checks out the right files;,$(…)and backticks is checked out as a literal directory and runs nothing (the test fails if that step goes back to string interpolation)refs/tags/-release) clonesvcsunit suites pass for all seven adapters (GitHub, GitLab, Gitea, Bitbucket, Origin, Forgejo, Gogs), including branch and commit values starting with a dash (rejected) and an unknown clone type (throws).vcsE2E clone tests now run the command and check the checked-out files instead of matching the command text. The tag test moves the branch past the tag and asserts the later file is absent.agentsDiffCheckTestpasses.Originhelpers against a local repository. A file named-n fis staged correctly and a multi-line commit message containing$(id)is committed as plain text.Deploymentsjob command shape undersh. A failed staging step still runs the build, and the build command reaches it as one unchanged argument.bin/monorepo validatepasses. Removed one stalephpstan-baseline.neonentry for an assertion this PR deletes.Related PRs and Issues
Utopia\Command)Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01XirP99UR2sHfDpCiioktcu