feat: Phase 2.7 quality improvements#14
Conversation
Add runnable examples to ConfigValue, ConfigStore, Remote, Project, Manifest::from_yaml_str, Workspace, Git, and CommandRegistry. Doc-tests go from 1 to 9 across the workspace.
Add miette dependency to east-vcs and derive Diagnostic on VcsError with actionable help hints. Completes the miette migration started in Phase 2.5 — all library crates now produce rich diagnostics.
Add a coverage job using cargo-llvm-cov to generate LCOV output and upload to Codecov. Upload failures do not block CI.
Read update.jobs from the layered config to control the max number of concurrent git operations in east update. Falls back to 8 if not set. Users configure it with: east config set --int update.jobs N
Add phase-2.7.md and phase-2.7.zh-CN.md covering doc-tests, miette unification, CI coverage, and configurable concurrency. Bump README status to Phase 2.7.
Replace "住在" (literal translation of "lives in") with "存放于", and "钳位" with "限制为最小" for more natural technical Chinese.
There was a problem hiding this comment.
Pull request overview
Phase 2.7 quality improvements across the Rust workspace: expands doc-test coverage for core public APIs, completes miette diagnostics adoption for east-vcs, adds CI coverage reporting, and makes east update concurrency configurable, with accompanying documentation/README updates.
Changes:
- Add runnable doc examples (doctests) to core public APIs across multiple crates.
- Derive
miette::Diagnosticforeast-vcs::VcsErrorand add actionable help hints. - Add a CI coverage job using
cargo-llvm-covand Codecov; makeeast updatereadupdate.jobsfrom config.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates status to Phase 2.7 and adds a Phase 2.7 bullet. |
| README.zh-CN.md | Updates status to Phase 2.7 and refines Phase wording in zh-CN. |
| docs/dev/phase-2.7.md | Adds Phase 2.7 development notes (EN). |
| docs/dev/phase-2.7.zh-CN.md | Adds Phase 2.7 development notes (zh-CN). |
| docs/dev/phase-2.6.zh-CN.md | Wording refinement (zh-CN). |
| docs/design/phase-2.6.zh-CN.md | Wording refinement (zh-CN). |
| crates/east-workspace/src/workspace.rs | Adds a Workspace doc example/doctest. |
| crates/east-vcs/src/git.rs | Adds a Git doc example/doctest. |
| crates/east-vcs/src/error.rs | Migrates VcsError to miette::Diagnostic + help hints. |
| crates/east-vcs/Cargo.toml | Adds miette dependency via workspace. |
| crates/east-manifest/src/model.rs | Adds doc examples for Remote, Project, and Manifest::from_yaml_str. |
| crates/east-config/src/value.rs | Adds ConfigValue doc example/doctest. |
| crates/east-config/src/store.rs | Adds ConfigStore doc examples/doctests. |
| crates/east-command/src/registry.rs | Adds CommandRegistry::from_manifest doc example/doctest. |
| crates/east-cli/src/main.rs | Reads update.jobs from config to set update concurrency. |
| .github/workflows/ci.yml | Adds coverage job (llvm-cov + Codecov upload). |
| Cargo.lock | Records miette dependency for east-vcs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// let sha = Git::head(Path::new("./repo")).await?; | ||
| /// let dirty = Git::is_dirty(Path::new("./repo")).await?; | ||
| /// # Ok(()) | ||
| /// # } |
There was a problem hiding this comment.
The doc example starts a fenced Rust code block (no_run) but never closes it with a terminating line. This can break rustdoc rendering and may prevent the snippet from being recognized as a doctest; add the closing fence before pub struct Git;.
| /// # } | |
| /// # } | |
| /// ``` |
| pub enum VcsError { | ||
| /// A git command failed with a non-zero exit code. | ||
| #[error("git command failed in {path}: {stderr}")] | ||
| #[error("git command failed in {path}")] |
There was a problem hiding this comment.
VcsError::GitFailed no longer includes the git stderr in its Display message. The CLI formats failures with {e}, so this change will hide the most useful debugging context (e.g., auth failures, missing refs); consider including stderr (possibly trimmed/truncated) in the error text or otherwise ensuring it’s surfaced in user-facing output.
| #[error("git command failed in {path}")] | |
| #[error("git command failed in {path}: {stderr}")] |
| #[error("git command failed in {path}")] | ||
| #[diagnostic(help("check that the repository exists and the revision is valid"))] | ||
| GitFailed { | ||
| /// Working directory or target path. | ||
| path: PathBuf, | ||
| /// The stderr output from git. | ||
| #[source_code] |
There was a problem hiding this comment.
#[source_code] is intended for source text that can be spanned/labeled in miette reports; using it for arbitrary git stderr is unusual and (without labels) may not display anything useful. Consider removing #[source_code] here, or switching to a more appropriate diagnostic field/format (e.g., keep stderr in the main error message or attach it as a note/help).
| #[error("git command failed in {path}")] | |
| #[diagnostic(help("check that the repository exists and the revision is valid"))] | |
| GitFailed { | |
| /// Working directory or target path. | |
| path: PathBuf, | |
| /// The stderr output from git. | |
| #[source_code] | |
| #[error("git command failed in {path}: {stderr}")] | |
| #[diagnostic(help("check that the repository exists and the revision is valid"))] | |
| GitFailed { | |
| /// Working directory or target path. | |
| path: PathBuf, | |
| /// The stderr output from git. |
| let cfg = Config::load_with_provider(&provider).into_diagnostic()?; | ||
| cfg.get("update.jobs") | ||
| .and_then(|v| v.as_i64()) | ||
| .map_or(DEFAULT_CONCURRENT_GIT, |n| n.max(1) as usize) |
There was a problem hiding this comment.
n.max(1) as usize will silently truncate/wrap for very large update.jobs values (and would behave differently on 32-bit targets). Prefer converting with usize::try_from(n) and clamping/saturating on overflow so invalid config values don’t yield surprising semaphore sizes.
| .map_or(DEFAULT_CONCURRENT_GIT, |n| n.max(1) as usize) | |
| .map_or(DEFAULT_CONCURRENT_GIT, |n| { | |
| let n = n.max(1); | |
| usize::try_from(n).unwrap_or(usize::MAX) | |
| }) |
- Close doc-test fenced code block on Git struct - Restore stderr in VcsError::GitFailed display message and remove incorrect #[source_code] attribute - Use usize::try_from instead of bare `as usize` cast for update.jobs to avoid silent truncation on 32-bit targets
Fixes clippy::redundant_closure_for_method_calls under pedantic.
Summary
miette::DiagnosticonVcsErrorwith actionable help hints, completing the miette migrationcargo-llvm-cov+ Codecov upload job to CI workfloweast updatereadsupdate.jobsfrom config instead of hardcodedSemaphore(8), set viaeast config set --int update.jobs NTest plan
cargo test --workspace— all ~164 tests pass (including 9 new doc-tests)cargo clippy --workspace— zero warnings