diff options
Diffstat (limited to 'crates/mozart-core/src/downloader/git_downloader.rs')
| -rw-r--r-- | crates/mozart-core/src/downloader/git_downloader.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/crates/mozart-core/src/downloader/git_downloader.rs b/crates/mozart-core/src/downloader/git_downloader.rs index d4d8c44..6e1351c 100644 --- a/crates/mozart-core/src/downloader/git_downloader.rs +++ b/crates/mozart-core/src/downloader/git_downloader.rs @@ -1,12 +1,11 @@ +use crate::downloader::{DownloaderInterface, VcsDownloader}; +use crate::vcs::process::ProcessExecutor; +use crate::vcs::util::git::GitUtil; use anyhow::Result; use regex::Regex; use std::path::Path; use std::sync::LazyLock; -use crate::downloader::VcsDownloader; -use crate::vcs::process::ProcessExecutor; -use crate::vcs::util::git::GitUtil; - /// Match `<hex> HEAD` lines in `git show-ref --head -d` output. static HEAD_REF_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?im)^([a-f0-9]+) HEAD$").unwrap()); @@ -19,8 +18,10 @@ pub struct GitDownloader { } impl GitDownloader { - pub fn new(git_util: GitUtil) -> Self { - Self { git_util } + pub fn new(process: ProcessExecutor, cache_dir: std::path::PathBuf) -> Self { + Self { + git_util: GitUtil::new(process, cache_dir), + } } } @@ -235,6 +236,12 @@ impl VcsDownloader for GitDownloader { } } +impl DownloaderInterface for GitDownloader { + fn as_vcs_downloader(&self) -> Option<&dyn VcsDownloader> { + Some(self) + } +} + fn collect_show_ref(process: &ProcessExecutor, target: &Path) -> Result<Option<String>> { let output = process.execute(&["git", "show-ref", "--head", "-d"], Some(target))?; if output.status != 0 { |
