mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 19:10:35 +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)
|
.write_to(&directory, project.cas_dir(), false)
|
||||||
.context("failed to write package contents")?;
|
.context("failed to write package contents")?;
|
||||||
|
|
||||||
// TODO: if MANIFEST_FILE_NAME does not exist, try to convert it
|
|
||||||
|
|
||||||
setup_patches_repo(&directory)?;
|
setup_patches_repo(&directory)?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use crate::cli::IsUpToDate;
|
use crate::cli::IsUpToDate;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use pesde::{
|
use pesde::{names::PackageNames, patches::create_patch, source::version_id::VersionId, Project};
|
||||||
manifest::Manifest, names::PackageNames, patches::create_patch, source::version_id::VersionId,
|
|
||||||
Project, MANIFEST_FILE_NAME,
|
|
||||||
};
|
|
||||||
use std::{path::PathBuf, str::FromStr};
|
use std::{path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
|
@ -22,17 +19,28 @@ impl PatchCommitCommand {
|
||||||
anyhow::bail!("outdated lockfile, please run the install command first")
|
anyhow::bail!("outdated lockfile, please run the install command first")
|
||||||
};
|
};
|
||||||
|
|
||||||
let (name, version_id) = {
|
let (name, version_id) = (
|
||||||
let patched_manifest = std::fs::read_to_string(self.directory.join(MANIFEST_FILE_NAME))
|
PackageNames::from_escaped(
|
||||||
.context("failed to read patched manifest")?;
|
self.directory
|
||||||
let patched_manifest: Manifest =
|
.parent()
|
||||||
toml::from_str(&patched_manifest).context("failed to parse patched manifest")?;
|
.context("directory has no parent")?
|
||||||
|
.parent()
|
||||||
(
|
.context("directory has no grandparent")?
|
||||||
PackageNames::Pesde(patched_manifest.name),
|
.file_name()
|
||||||
VersionId::new(patched_manifest.version, patched_manifest.target.kind()),
|
.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
|
graph
|
||||||
.get(&name)
|
.get(&name)
|
||||||
|
|
|
@ -104,6 +104,11 @@ impl PackageNames {
|
||||||
PackageNames::Wally(name) => name.escaped(),
|
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 {
|
impl Display for PackageNames {
|
||||||
|
|
|
@ -29,6 +29,11 @@ impl VersionId {
|
||||||
pub fn escaped(&self) -> String {
|
pub fn escaped(&self) -> String {
|
||||||
format!("{}+{}", self.0, self.1)
|
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 {
|
impl Display for VersionId {
|
||||||
|
|
Loading…
Reference in a new issue