mirror of
https://github.com/FuelLabs/sway.git
synced 2025-12-23 10:11:56 +00:00
|
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
## 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
|
||
|---|---|---|
| .. | ||
| src | ||
| tests | ||
| Cargo.toml | ||