mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: support wally dependency patching
This commit is contained in:
parent
957689c13a
commit
d8db84a751
4 changed files with 33 additions and 17 deletions
|
@ -45,8 +45,6 @@ impl PatchCommand {
|
|||
.write_to(&directory, project.cas_dir(), false)
|
||||
.context("failed to write package contents")?;
|
||||
|
||||
// TODO: if MANIFEST_FILE_NAME does not exist, try to convert it
|
||||
|
||||
setup_patches_repo(&directory)?;
|
||||
|
||||
println!(
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
use crate::cli::IsUpToDate;
|
||||
use anyhow::Context;
|
||||
use clap::Args;
|
||||
use pesde::{
|
||||
manifest::Manifest, names::PackageNames, patches::create_patch, source::version_id::VersionId,
|
||||
Project, MANIFEST_FILE_NAME,
|
||||
};
|
||||
use pesde::{names::PackageNames, patches::create_patch, source::version_id::VersionId, Project};
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
@ -22,17 +19,28 @@ impl PatchCommitCommand {
|
|||
anyhow::bail!("outdated lockfile, please run the install command first")
|
||||
};
|
||||
|
||||
let (name, version_id) = {
|
||||
let patched_manifest = std::fs::read_to_string(self.directory.join(MANIFEST_FILE_NAME))
|
||||
.context("failed to read patched manifest")?;
|
||||
let patched_manifest: Manifest =
|
||||
toml::from_str(&patched_manifest).context("failed to parse patched manifest")?;
|
||||
|
||||
(
|
||||
PackageNames::Pesde(patched_manifest.name),
|
||||
VersionId::new(patched_manifest.version, patched_manifest.target.kind()),
|
||||
)
|
||||
};
|
||||
let (name, version_id) = (
|
||||
PackageNames::from_escaped(
|
||||
self.directory
|
||||
.parent()
|
||||
.context("directory has no parent")?
|
||||
.parent()
|
||||
.context("directory has no grandparent")?
|
||||
.file_name()
|
||||
.context("directory grandparent has no name")?
|
||||
.to_str()
|
||||
.context("directory grandparent name is not valid")?,
|
||||
)?,
|
||||
VersionId::from_escaped(
|
||||
self.directory
|
||||
.parent()
|
||||
.context("directory has no parent")?
|
||||
.file_name()
|
||||
.context("directory parent has no name")?
|
||||
.to_str()
|
||||
.context("directory parent name is not valid")?,
|
||||
)?,
|
||||
);
|
||||
|
||||
graph
|
||||
.get(&name)
|
||||
|
|
|
@ -104,6 +104,11 @@ impl PackageNames {
|
|||
PackageNames::Wally(name) => name.escaped(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The reverse of `escaped`
|
||||
pub fn from_escaped(s: &str) -> Result<Self, errors::PackageNamesError> {
|
||||
PackageNames::from_str(s.replacen('+', "/", 1).as_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for PackageNames {
|
||||
|
|
|
@ -29,6 +29,11 @@ impl VersionId {
|
|||
pub fn escaped(&self) -> String {
|
||||
format!("{}+{}", self.0, self.1)
|
||||
}
|
||||
|
||||
/// The reverse of `escaped`
|
||||
pub fn from_escaped(s: &str) -> Result<Self, errors::VersionIdParseError> {
|
||||
VersionId::from_str(s.replacen('+', " ", 1).as_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for VersionId {
|
||||
|
|
Loading…
Reference in a new issue