Skip to main content

execute_sync

Function execute_sync 

Source
pub async fn execute_sync(manifest_path: &str) -> Result<SyncReport, SyncError>
Expand description

Align every local path entry under [workspace.dependencies] with the workspace root version, and (optionally) the dep alias with the member crate’s actual [package].name.

§Arguments

  • &str: Path to the workspace root Cargo.toml.

§Returns

  • Result<SyncReport, SyncError>: Summary of what was rewritten.

§Behavior

  • Reads the root version via read_root_version (workspace package version first, plain package version as fallback). Errors out if neither exists.
  • Reads [workspace.members]. Errors out if it is missing.
  • When the root manifest also has [package] (monorepo with a root package), the root package itself is processed first as member path ".", so a path = "." entry stays aligned too.
  • For each member path:
    1. Opens <member_path>/Cargo.toml and reads its [package].name.
    2. Locates the existing [workspace.dependencies] entry whose path = \"<member_path>\" and captures its current LHS alias.
    3. If the entry is already aligned (alias + version both correct), skip it.
    4. Otherwise rewrite the entry in-place: align version to the root version, and rename the LHS alias to match the crate’s [package].name when the alias differs.
  • Edits are applied on a toml_edit::DocumentMut, so comments, key order and inline-table formatting outside the edited values are preserved byte-for-byte.
  • file_changed is true iff at least one rename or version-rewrite actually happened (so a no-op run is genuinely idempotent and does not write the file).