Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve package name-version dir prefix #155

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ impl Distribution {

/// Make the path relative to the archive root
fn relative_to_archive_root(&self, path: &Path) -> Result<PathBuf> {
// Use strip prefix to remove the tempdir path, then skip the archive dir
Ok(path.strip_prefix(self.dir.path())?.iter().skip(1).collect())
Ok(path.strip_prefix(self.dir.path())?.to_path_buf())
}
}

Expand Down Expand Up @@ -582,10 +581,6 @@ mod tests {

let result = distro.scan_file(tmpfile.path(), &rules).unwrap();

assert_eq!(
result.path,
tmpfile.path().strip_prefix(archive_root.path()).unwrap()
);
assert_eq!(
result.rules[0],
RuleScore {
Expand All @@ -600,8 +595,8 @@ mod tests {
fn test_relative_to_archive_root() {
let tempdir = tempdir().unwrap();

let input_path = &tempdir.path().join("package-name").join("README.md");
let expected_path = PathBuf::from("README.md");
let input_path = &tempdir.path().join("name-version").join("README.md");
let expected_path = PathBuf::from("name-version/README.md");

let distro = super::Distribution {
dir: tempdir,
Expand Down
Loading