Commit d7d5099
authored
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
089422a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 8930fe8 commit d7d5099
File tree
4 files changed
+389
-9
lines changed- docs/book/src/forc
- forc-pkg/src/source
- reg
4 files changed
+389
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| |||
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
263 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
264 | 301 | | |
265 | 302 | | |
266 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | 41 | | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
| |||
0 commit comments