fix: handle missing revision properly

This commit is contained in:
daimond113 2024-10-13 15:18:05 +02:00
parent 15df417472
commit b3f0a3cbfb
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 3 additions and 2 deletions

View file

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Correct `pesde.toml` inclusion message in `publish` command by @daimond113 - Correct `pesde.toml` inclusion message in `publish` command by @daimond113
- Allow writes to files when `link` is false in PackageFS::write_to by @daimond113 - Allow writes to files when `link` is false in PackageFS::write_to by @daimond113
- Handle missing revisions in AnyPackageIdentifier::from_str by @daimond113
## [0.5.0-rc.5] - 2024-10-12 ## [0.5.0-rc.5] - 2024-10-12
### Added ### Added

View file

@ -163,7 +163,7 @@ impl<V: FromStr<Err = E>, E: Into<anyhow::Error>, N: FromStr<Err = F>, F: Into<a
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some(s) = s.strip_prefix("gh#") { if let Some(s) = s.strip_prefix("gh#") {
let s = format!("https://github.com/{s}"); let s = format!("https://github.com/{s}");
let (repo, rev) = s.split_once('#').unwrap(); let (repo, rev) = s.split_once('#').context("missing revision")?;
Ok(AnyPackageIdentifier::Url(( Ok(AnyPackageIdentifier::Url((
repo.try_into()?, repo.try_into()?,
@ -172,7 +172,7 @@ impl<V: FromStr<Err = E>, E: Into<anyhow::Error>, N: FromStr<Err = F>, F: Into<a
} else if let Some(rest) = s.strip_prefix("workspace:") { } else if let Some(rest) = s.strip_prefix("workspace:") {
Ok(AnyPackageIdentifier::Workspace(rest.parse()?)) Ok(AnyPackageIdentifier::Workspace(rest.parse()?))
} else if s.contains(':') { } else if s.contains(':') {
let (url, rev) = s.split_once('#').unwrap(); let (url, rev) = s.split_once('#').context("missing revision")?;
Ok(AnyPackageIdentifier::Url(( Ok(AnyPackageIdentifier::Url((
url.try_into()?, url.try_into()?,