sway/forc-pkg
kaya d7d5099eae
Some checks are pending
Codspeed Benchmarks / benchmarks (push) Waiting to run
CI / get-fuel-core-version (push) Waiting to run
CI / build-sway-lib-std (push) Waiting to run
CI / check-forc-manifest-version (push) Waiting to run
CI / verifications-complete (push) Blocked by required conditions
CI / check-dependency-version-formats (push) Waiting to run
CI / build-sway-examples (push) Waiting to run
CI / build-reference-examples (push) Waiting to run
CI / forc-fmt-check-sway-lib-std (push) Waiting to run
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-run-benchmarks (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
CI / Build and test various forc tools (push) Blocked by required conditions
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / pre-publish-check (push) Waiting to run
CI / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
feat: add support for patching registry dependencies (#7469)
## Overview

Implements support for patching registry dependencies (from forc.pub)
using the `[patch]` table in `Forc.toml`. Previously, only Git
dependencies could be patched, which created a workflow gap when
packages like `std` migrated from Git to the registry.

## Motivation

When `std` and other core packages moved to forc.pub registry,
developers lost the ability to:
- Test local changes to standard library code
- Use unreleased features from development branches
- Debug issues with instrumented versions of dependencies

This PR restores that capability by extending the existing patch system
to support registry packages.

## Implementation

### Key Features

1. **Registry Patching**: Use `[patch.'forc.pub']` to override registry
dependencies
2. **Multiple Source Types**: Patch with local path or Git repository
3. **Namespace Support**: Built-in support for namespaced packages
(implementation-ready for future use)
4. **Priority System**: Namespace-specific patches override generic
patches

## Usage

### Basic Usage

```toml
[dependencies]
std = "0.70.1"

[patch.'forc.pub']
std = { path = "../sway/sway-lib-std" }
```

### Patch with Git Branch

```toml
[dependencies]
std = "0.70.1"

[patch.'forc.pub']
std = { git = "https://github.com/fuellabs/sway", branch = "my-feature" }
```

### Workspace-Level Patches

```toml
[workspace]
members = ["contract-a", "contract-b"]

[patch.'forc.pub']
std = { path = "../custom-std" }
```

## Documentation

Updated user documentation in:
- `docs/book/src/forc/manifest_reference.md` - Complete patch section
rewrite with examples
- `docs/book/src/forc/workspaces.md` - Added registry patching examples
- Inline code documentation with TOML syntax notes

## Breaking Changes

None. This is a purely additive change. All existing Git patches
continue to work exactly as before.

## Notes

- **TOML Syntax**: Quotes are required: `[patch.'forc.pub']` not
`[patch.forc.pub]`
- **Source Matching**: Registry patches only apply to registry
dependencies
- **Namespace Support**: Implementation includes namespace support

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds support to patch registry dependencies using `[patch.'forc.pub']`
(with namespaced overrides and fallback), keeps Git patching intact, and
updates docs with examples.
> 
> - **Core (forc-pkg)**:
> - Extend `Source::dep_patch` to handle registry sources: checks
`[patch.'forc.pub/<namespace>']` first, then `[patch.'forc.pub']`; Git
patching unchanged.
>   - Add `reg::REGISTRY_PATCH_KEY` constant (`"forc.pub"`).
> - **Tests**:
> - Add unit tests covering flat/domain namespaces, namespace priority
vs. generic fallback, Git patch compatibility, and no-op cases.
> - **Docs**:
> - Update `docs/book/src/forc/manifest_reference.md` with registry
patching examples, notes on quoting keys, and clarifications.
> - Update `docs/book/src/forc/workspaces.md` with Git and registry
patching examples for workspaces.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
089422addf. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-11-20 00:34:47 -08:00
..
src feat: add support for patching registry dependencies (#7469) 2025-11-20 00:34:47 -08:00
tests Implement a command to dump impls for a given type (#7322) 2025-08-26 16:02:16 -07:00
Cargo.toml chore: bumpt rust version to 1.90 (#7427) 2025-10-02 22:28:51 +13:00