Refactor and enhance source management and installation processes
- Improved error handling and context messages in `checkout` function in `git.rs`. - Updated license field in package specification to use a vector in `hooks.rs`. - Enhanced `copy_manual_sources` function in `mod.rs` to support both local file and remote URL sources, including checksum verification. - Added new utility functions for path normalization and skipping installation of specific files in `staging/mod.rs`. - Implemented logic to handle existing files during installation, allowing for `.depotnew` suffix for kept files. - Added tests for manual source copying, installation behavior, and path validation. - Introduced a new LICENSE file with MIT License terms.
This commit is contained in:
+13
-6
@@ -19,15 +19,23 @@ pub fn checkout(
|
||||
git_cache_dir: &Path,
|
||||
pkgname: &str,
|
||||
) -> Result<()> {
|
||||
fs::create_dir_all(git_cache_dir)
|
||||
.with_context(|| format!("Failed to create git cache dir: {}", git_cache_dir.display()))?;
|
||||
fs::create_dir_all(git_cache_dir).with_context(|| {
|
||||
format!(
|
||||
"Failed to create git cache dir: {}",
|
||||
git_cache_dir.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
let mirror_dir = git_cache_dir.join(mirror_key(url));
|
||||
ensure_mirror(url, &mirror_dir, pkgname)?;
|
||||
|
||||
if checkout_dir.exists() {
|
||||
fs::remove_dir_all(checkout_dir)
|
||||
.with_context(|| format!("Failed to remove existing checkout: {}", checkout_dir.display()))?;
|
||||
fs::remove_dir_all(checkout_dir).with_context(|| {
|
||||
format!(
|
||||
"Failed to remove existing checkout: {}",
|
||||
checkout_dir.display()
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
// Clone from local mirror for speed.
|
||||
@@ -40,8 +48,7 @@ pub fn checkout(
|
||||
.with_context(|| format!("Failed to clone from mirror for {}", url))?;
|
||||
|
||||
let repo = Repository::open(checkout_dir)?;
|
||||
checkout_rev(&repo, rev)
|
||||
.with_context(|| format!("Failed to checkout revision '{}'", rev))?;
|
||||
checkout_rev(&repo, rev).with_context(|| format!("Failed to checkout revision '{}'", rev))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user