Skip to main content

Crate composer_patches

Crate composer_patches 

Source
Expand description

Native reimplementation of the cweagans/composer-patches plugin.

this crate never runs the PHP plugin (per the no-plugins invariant); this crate reproduces its effect: resolve the set of (target package → [patches]) from the root project, materialize each patch, and apply it to the freshly-extracted package tree during install. Patches are applied in-process with the flickzeug fuzzy-matching diff library — never by shelling out to git apply / patch — so behavior is identical across Linux, macOS, and Windows.

The crate is intentionally FS/PHP-agnostic, like composer-installers and the sibling installer crates: it parses, plans, and applies; the host (composer-install’s install orchestrator) decides when to call it and wires it into the install lifecycle.

§Module map

  • model — the internal Patch model + v1/v2 dialect normalization.
  • diff — multi-file diff splitting + -p path stripping (over flickzeug).
  • build — build a project’s PatchPlan from its composer.json.
  • apply — apply a patch to a tree with the -p fallback loop.
  • make — author a patch from an edited tree (the inverse of apply).
  • resolve — build the root patch set from composer.json + patches-file.
  • plan — the materialized PatchPlan + re-application fingerprints.
  • pass — the per-package apply pass (+ PATCHES.txt).
  • lock — the patches.lock.json applied-state store.
  • target — the patches/ dir header-inference router.
  • report — per-application outcome (ApplyReport).

Re-exports§

pub use apply::ApplyOptions;
pub use apply::apply_patch_text;
pub use build::NoFetch;
pub use build::PatchFetcher;
pub use build::PlanOptions;
pub use build::build_plan;
pub use build::lock_install_paths;
pub use build::patches_dir_name;
pub use build::resolve_all;
pub use model::DepthSpec;
pub use model::FailureMode;
pub use model::Patch;
pub use model::PatchScope;
pub use model::PatchSource;
pub use model::parse_target_patches;
pub use pass::PackageApplyResult;
pub use pass::append_patches_txt;
pub use pass::apply_package_patches;
pub use plan::DeferredPatch;
pub use plan::MaterializedPatch;
pub use plan::PatchPlan;
pub use plan::RootPatch;
pub use plan::fingerprint;
pub use report::ApplyReport;
pub use report::FileAction;
pub use report::FileOutcome;
pub use resolve::resolve_patches_dir;
pub use resolve::resolve_root;
pub use target::InferredTarget;
pub use target::infer_target;

Modules§

apply
Apply a patch file to a tree on disk.
build
Build a project’s PatchPlan from its root composer.json.
diff
Unified/git-diff parsing: split a (possibly multi-file) patch into per-file units, expose each file’s raw header paths, and -p-strip them.
lock
patches.lock.json — the applied-state store that makes re-application correct.
make
Author a patch from an edited package tree — the inverse of apply.
model
The internal patch model and the normalization of cweagans’ v1/v2 composer.json dialects into it.
pass
The per-package apply pass the install orchestrator drives after a package has been (re-)extracted pristine.
plan
The materialized patch plan handed to the install orchestrator.
report
Outcome reporting for a patch application: per-file actions, aggregate line stats, and (Phase B) the PATCHES.txt writer.
resolve
Build the resolved patch set from the root project.
target
Target inference for the zero-config patches/ directory.

Functions§

content_sha256
Lowercase hex sha256 of arbitrary bytes.