summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/manifest.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/manifest.rs b/src/manifest.rs
index 8e9d13c..3a34af7 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -46,14 +46,26 @@ impl ArtifactManifest {
}
pub fn write_beside(&self, artifact: impl AsRef<Path>) -> Result<PathBuf> {
- let artifact = artifact.as_ref();
- let directory = artifact.parent().unwrap_or_else(|| Path::new("."));
- let path = directory.join("artifact.manifest.toml");
+ let path = Self::path_beside(artifact)?;
let text = toml::to_string_pretty(self).context("serialize artifact manifest")?;
fs::write(&path, text).with_context(|| format!("write artifact manifest {}", path.display()))?;
Ok(path)
}
+ /// Return the unambiguous companion-manifest path for one artifact.
+ /// Keeping the artifact filename prevents legacy and native manifests from
+ /// overwriting one another when both are written to the comparison output
+ /// directory.
+ pub fn path_beside(artifact: impl AsRef<Path>) -> Result<PathBuf> {
+ let artifact = artifact.as_ref();
+ let name = artifact
+ .file_name()
+ .ok_or_else(|| anyhow::anyhow!("artifact path has no filename: {}", artifact.display()))?;
+ let mut manifest_name = name.to_os_string();
+ manifest_name.push(".manifest.toml");
+ Ok(artifact.with_file_name(manifest_name))
+ }
+
/// Collect native filesystem and archive facts from a completed build.
/// Package records come from the typed package-installation boundary because
/// the RPM database is not a portable filesystem format.