Skip to content

Commit

Permalink
fix lint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
kattouf committed Jun 2, 2024
1 parent ff3326e commit f293cc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion e2e/backend/test_spm_slow
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Enable test when `Swift` installation will be fixed on Linux (for docker run)
# Wait for https://github.com/jdx/mise/pull/1708
exit 0;
exit 0

mise use swift

Expand Down
21 changes: 8 additions & 13 deletions src/backend/spm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ impl SPMBackend {
package_repo: &SwiftPackageRepo,
revision: &str,
) -> Result<PathBuf, eyre::Error> {
let tmp_repo_dir = temp_dir()
.join("spm")
.join(&package_repo.dir_name(revision));
let tmp_repo_dir = temp_dir().join("spm").join(package_repo.dir_name(revision));
file::remove_all(&tmp_repo_dir)?;
file::create_dir_all(tmp_repo_dir.parent().unwrap())?;

Expand All @@ -113,7 +111,7 @@ impl SPMBackend {
tmp_repo_dir.display()
);
let repo = Repository::clone(package_repo.url.as_str(), &tmp_repo_dir)?;
let (object, reference) = repo.revparse_ext(&revision)?;
let (object, reference) = repo.revparse_ext(revision)?;
repo.checkout_tree(&object, None)?;
repo.set_head(reference.unwrap().name().unwrap())?;
Ok(tmp_repo_dir)
Expand Down Expand Up @@ -181,12 +179,9 @@ impl SPMBackend {
"Copying binaries to install path: {}",
install_bin_path.display()
);
file::create_dir_all(&install_bin_path)?;
file::copy(
&bin_path.join(&executable),
&install_bin_path.join(&executable),
)?;
WalkDir::new(&bin_path)
file::create_dir_all(install_bin_path)?;
file::copy(bin_path.join(executable), install_bin_path.join(executable))?;
WalkDir::new(bin_path)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| {
Expand All @@ -195,9 +190,9 @@ impl SPMBackend {
ext == "dylib" || ext == "bundle"
})
.try_for_each(|e| -> Result<(), eyre::Error> {
let rel_path = e.path().strip_prefix(&bin_path)?;
let rel_path = e.path().strip_prefix(bin_path)?;
let install_path = install_bin_path.join(rel_path);
file::create_dir_all(&install_path.parent().unwrap())?;
file::create_dir_all(install_path.parent().unwrap())?;
if e.path().is_dir() {
file::copy_dir_all(e.path(), &install_path)?;
} else {
Expand Down Expand Up @@ -241,7 +236,7 @@ impl SwiftPackageRepo {
}

fn dir_name(&self, revision: &str) -> String {
self.shorthand.replace("/", "-") + "@" + revision
self.shorthand.replace('/', "-") + "@" + revision
}
}

Expand Down

0 comments on commit f293cc4

Please sign in to comment.