forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(forc-pkg): Unify member source types, fix manifest entries, fix F…
…uelLabs#4235 (FuelLabs#4237) ## Description Fixes an issue where member source types unintentionally omitted entries from the manifest map during the fetch traversal after the source refactor in FuelLabs#4168. Tested locally with the `fuels-rs` test suite using the steps described in FuelLabs#4235. Closes FuelLabs#4235. This patch will likely also apply to other large workspaces too, we might want to consider cutting a patch release soon after landing. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
- Loading branch information
1 parent
89f29e7
commit 0dcae3d
Showing
3 changed files
with
77 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::{manifest::PackageManifestFile, source}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::{ | ||
fmt, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
/// Member source representation as a canonical path. | ||
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)] | ||
pub struct Source(pub(super) PathBuf); | ||
|
||
/// A pinned instance of a member source requires no information as it's a part | ||
/// of the workspace. | ||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] | ||
pub struct Pinned; | ||
|
||
impl fmt::Display for Pinned { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "member") | ||
} | ||
} | ||
|
||
impl source::Pin for Source { | ||
type Pinned = Pinned; | ||
fn pin(&self, _ctx: source::PinCtx) -> anyhow::Result<(Self::Pinned, PathBuf)> { | ||
Ok((Pinned, self.0.clone())) | ||
} | ||
} | ||
|
||
impl source::Fetch for Pinned { | ||
fn fetch(&self, _ctx: source::PinCtx, local: &Path) -> anyhow::Result<PackageManifestFile> { | ||
let manifest = PackageManifestFile::from_dir(local)?; | ||
Ok(manifest) | ||
} | ||
} | ||
|
||
impl source::DepPath for Pinned { | ||
fn dep_path(&self, _name: &str) -> anyhow::Result<source::DependencyPath> { | ||
Ok(source::DependencyPath::Member) | ||
} | ||
} | ||
|
||
impl From<Pinned> for source::Pinned { | ||
fn from(p: Pinned) -> Self { | ||
Self::Member(p) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters