-
Notifications
You must be signed in to change notification settings - Fork 122
refactor(cl) refactor cl operation by introducing OneditService #1910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(cl) refactor cl operation by introducing OneditService #1910
Conversation
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
|
标题应为 |
|
@codex review |
|
Claude finished @genedna's task in 2m 38s —— View job Code Review Complete ✅I've completed a comprehensive review of this refactoring PR. Overall, this is a well-structured refactoring that successfully introduces the SummaryThis PR refactors CL-related operations from Architectural Review✅ Strengths
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83739b0b01
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Ok(EditFileResult { | ||
| commit_id: new_commit_id, | ||
| new_oid: new_blob.id.to_string(), | ||
| path: payload.path, | ||
| path: repo_path.to_string(), | ||
| cl_link: Some(cl.link), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return edited file path in edit response
The edit response now sets path to the repo root (/) instead of the file path that was actually edited. EditFileResult.path is documented as the saved file path, and clients are likely to use it to refresh file views or build follow‑up requests. With this change, every edit response reports /, which misleads consumers even when the edit succeeds.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors CL (Change List) operations around a new ceres::code_edit module to support a standardized “file edit → CL → build” flow by centralizing CL creation/update, reviewer assignment, conflict/check handling, and build triggering.
Changes:
- Introduce
ceres::code_editmodule with a genericCodeEditServiceand shared utilities for CL-related workflows. - Refactor git-push (
MonoRepo::post_receive_pack) and file-edit (MonoApiService::save_file_edit) flows to useOnpushCodeEdit/OneditCodeEdit. - Reuse shared
cl_files_listlogic and makecollect_commit_blobspublic for cross-module use.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| ceres/src/pack/monorepo.rs | Switch post-push CL handling/build triggering to OnpushCodeEdit; adjust reanchor to take cl model. |
| ceres/src/lib.rs | Export new code_edit module. |
| ceres/src/code_edit/mod.rs | New module wiring for code-edit services. |
| ceres/src/code_edit/model.rs | Introduce generic CodeEditService abstraction for CL workflows (create/update/build/check/reviewers). |
| ceres/src/code_edit/on_push.rs | Add on-push specialization types for CodeEditService. |
| ceres/src/code_edit/on_edit.rs | Add on-edit specialization types and CL selection logic for file edits. |
| ceres/src/code_edit/utils.rs | Extract shared CL diff/list + policy collection utilities. |
| ceres/src/api_service/mono_api_service.rs | Refactor file-edit CL creation + build trigger; reuse extracted diff logic. |
| ceres/src/api_service/commit_ops.rs | Make collect_commit_blobs public for reuse by code_edit utilities. |
| let dst_commit = Commit::from_mega_model( | ||
| storage | ||
| .mono_storage() | ||
| .get_commit_by_hash(to_hash) | ||
| .await? | ||
| .expect("invalid to_hash"), |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_new_cl() uses expect(...) for commit lookups (expect("invalid to_hash")). Panics in service code will crash the request; map missing/invalid commits to a MegaError with context instead of panicking.
| if self.bellatrix.enable_build() { | ||
| let _ = editor | ||
| .trigger_build_and_check( | ||
| self.storage.clone(), | ||
| self.git_object_cache.clone(), |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger_build_and_check(...).await? will fail the entire git push if build triggering/checking returns an error. Previously build triggering was best-effort (errors were logged and the push continued). If pushes shouldn’t be blocked by CI trigger issues, catch/log build-trigger errors instead of propagating them here.
| impl model::CLRefUpdateVisitor for OnpushVisitor { | ||
| async fn visit( | ||
| &self, | ||
| _: &mega_cl::Model, | ||
| _: &str, | ||
| _: &str, | ||
| ) -> Result<mega_refs::Model, MegaError> { | ||
| panic!("visit not implemented"); | ||
| } |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnpushVisitor::visit() panics. Any code path that ends up calling the visitor will crash the service. Replace the panic with a real implementation or return a structured MegaError until this is implemented.
| commit_hash: &str, | ||
| tree_hash: &str, | ||
| ) -> Result<(), MegaError> { | ||
| visitor.visit(cl, commit_hash, tree_hash).await?; | ||
| Ok(()) |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OneditAcceptor::accept() calls visitor.visit(...) but discards the returned mega_refs::Model, so no CL ref is actually saved. If CL ref creation/update is part of this refactor, persist the returned ref via storage (insert/update in mega_refs) instead of dropping it.
| commit_id: new_commit_id, | ||
| new_oid: new_blob.id.to_string(), | ||
| path: payload.path, | ||
| path: repo_path.to_string(), |
Copilot
AI
Feb 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EditFileResult.path is documented as the saved file path, but the response now returns "/" (repo_path) instead of payload.path. This is a breaking API/behavior change for clients. Return the actual saved file path.
| path: repo_path.to_string(), | |
| path: payload.path.clone(), |
benjamin-747
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要解决这些问题并解决合并冲突
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
Signed-off-by: Chen-Rong-Zi <1398881912@qq.com>
7388990
summary
为实现“文件编辑 → CL → 构建” 这一标准模型, 引入模块
CodeEditService其围绕
CL(Change List)这一核心抽象, 封装了代码变更场景下cl的相关操作, 将以下服务聚合为统一的整体cl_ref的创建与更新服务conversation自动创建服务reviewer的自动分配服务cl相关事件的自动构建服务TriggerBuilder以保证上层服务对cl统一的操作逻辑
CodeEditService同时保留了一定的扩展能力, 允许开发人员在代码变更场景新增其他基于cl的新服务逻辑或其他上层服务触发逻辑Related Issue
[r2cn] 支持编辑文件后自动创建 CL 并触发构建流程 #1872