feat: fixed detailed fs path not being preserved
This commit is contained in:
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
### Fxied
|
||||
|
||||
- Themes being saved in eiipm installed package database.
|
||||
- Detailed fs path not being preserved.
|
||||
|
||||
## [0.3.0] - 2025-08-22
|
||||
|
||||
|
||||
@@ -91,10 +91,17 @@ pub fn install_package(package_name: &str) -> Result<(), Box<dyn Error>> {
|
||||
.expect("Invalid glob")
|
||||
.filter_map(Result::ok)
|
||||
.map(|src_path| {
|
||||
let relative_path = src_path
|
||||
.strip_prefix(&repo_fs_path)
|
||||
.expect("Failed to get relative path");
|
||||
let tgt = match dest {
|
||||
Some(d) => target_base_dir.join(d),
|
||||
None => target_base_dir.join(src),
|
||||
Some(d) => {
|
||||
let sanitized = d.trim_end_matches('*').trim_end_matches('/');
|
||||
target_base_dir.join(sanitized).join(relative_path)
|
||||
}
|
||||
None => target_base_dir.join(relative_path),
|
||||
};
|
||||
|
||||
(src_path, tgt)
|
||||
})
|
||||
.collect(),
|
||||
|
||||
@@ -138,10 +138,17 @@ fn update_file(
|
||||
.expect("Invalid glob")
|
||||
.filter_map(Result::ok)
|
||||
.map(|src_path| {
|
||||
let relative_path = src_path
|
||||
.strip_prefix(&repo_fs_path)
|
||||
.expect("Failed to get relative path");
|
||||
let tgt = match dest {
|
||||
Some(d) => target_base_dir.join(d),
|
||||
None => target_base_dir.join(src),
|
||||
Some(d) => {
|
||||
let sanitized = d.trim_end_matches('*').trim_end_matches('/');
|
||||
target_base_dir.join(sanitized).join(relative_path)
|
||||
}
|
||||
None => target_base_dir.join(relative_path),
|
||||
};
|
||||
|
||||
(src_path, tgt)
|
||||
})
|
||||
.collect(),
|
||||
|
||||
@@ -19,6 +19,7 @@ pub fn init_and_fetch(
|
||||
) -> Result<Repository, Error> {
|
||||
// initialize new git repository
|
||||
let repo = Repository::init(path)?;
|
||||
set_temporary_identity(&repo)?;
|
||||
|
||||
repo.remote("origin", repo_url)?;
|
||||
|
||||
@@ -50,6 +51,7 @@ pub fn init_and_fetch(
|
||||
/// and discard all previous history (like a shallow reset).
|
||||
pub fn update_to_latest(repo_path: &Path, commit: &str, fetch_depth: i32) -> Result<(), Error> {
|
||||
let repo = Repository::open(repo_path)?;
|
||||
set_temporary_identity(&repo)?;
|
||||
|
||||
// Prepare fetch options (shallow)
|
||||
let callbacks = RemoteCallbacks::new();
|
||||
@@ -79,3 +81,11 @@ pub fn update_to_latest(repo_path: &Path, commit: &str, fetch_depth: i32) -> Res
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set a temporary identity in the repository configuration.
|
||||
fn set_temporary_identity(repo: &git2::Repository) -> Result<(), Error> {
|
||||
let mut config = repo.config()?;
|
||||
config.set_str("user.name", "eiipm-anon")?;
|
||||
config.set_str("user.email", "eiipm-anon@example.com")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user