Conversation
Clone a project (with volumes, credentials, git rebinding) to a target region or dedicated server. Polls cloneProjectStatus for progress and prints events until completion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a new CLI Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant Factory
participant API
participant GQL
User->>CLI: run `project clone`
CLI->>Factory: resolve params (project, env, region)
CLI->>API: CloneProject(projectID, envID, region, suspend)
API->>GQL: GraphQL mutation cloneProject
GQL-->>API: newProjectId
API-->>CLI: CloneProjectResult
loop poll
CLI->>API: CloneProjectStatus(newProjectId)
API->>GQL: GraphQL query cloneProjectStatus
GQL-->>API: events / status / error
API-->>CLI: CloneProjectStatusResult
CLI->>CLI: stream events, check completion
end
CLI->>User: final status + dashboard URL
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds a new zeabur project clone CLI command that triggers a backend clone operation and monitors progress until completion, enabling project duplication across regions/servers.
Changes:
- Introduce GraphQL models for clone mutation/status events.
- Add API client methods (
CloneProject,CloneProjectStatus) and expose them viaProjectAPI. - Register and implement the new
project cloneCobra subcommand (interactive + non-interactive flows).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/model/clone.go | Adds models for clone mutation result and status/event payloads. |
| pkg/api/project.go | Implements GraphQL mutation/query wrappers for project cloning and status polling. |
| pkg/api/interface.go | Extends ProjectAPI with clone-related methods. |
| internal/cmd/project/project.go | Registers the new project clone subcommand under project. |
| internal/cmd/project/clone/clone.go | Implements the zeabur project clone command UX and polling loop. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/cmd/project/clone/clone.go
Outdated
| // Poll for status | ||
| seenEvents := 0 | ||
| for { | ||
| time.Sleep(3 * time.Second) | ||
|
|
There was a problem hiding this comment.
The status polling loop has no cancellation/timeout and sleeps before the first status query, so the command can hang indefinitely (and always waits at least 3s even if the clone finishes/fails immediately). Consider using a ticker and selecting on a context with timeout/cancel (e.g., cmd context or a --timeout flag), and query status immediately before the first wait.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cmd/project/clone/clone.go`:
- Around line 104-119: The code builds availableRegions and regionOptions from
regions then calls f.Prompter.Select and uses availableRegions[regionIndex],
which will panic if availableRegions is empty; add an explicit guard after the
loop (check len(availableRegions) == 0) and return a clear error (or handle the
no-region case) before calling f.Prompter.Select so that f.Prompter.Select and
the subsequent access to availableRegions[regionIndex].GetID() are only executed
when availableRegions contains entries.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
internal/cmd/project/clone/clone.gointernal/cmd/project/project.gopkg/api/interface.gopkg/api/project.gopkg/model/clone.go
- Guard against empty availableRegions before prompting - Replace sleep loop with ticker + 10-minute context timeout Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
zeabur project clonecommand to clone a project (with volumes, credentials, git rebinding) to a target region or dedicated server--id,--region,--env-id,--suspend)cloneProjectStatusevery 3s and streams clone events until completionTest plan
zeabur project clone --id <id> --region hnd1 -i=false— cloned successfully to public regionzeabur project clone --id <id> --region server-<id> -i=false— cloned dify to dedicated server successfullyzeabur project clone --help— flags displayed correctly🤖 Generated with Claude Code
Summary by CodeRabbit