diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-24 21:10:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-24 21:11:03 +0900 |
| commit | a8f115666344abe3b606a4a65595ca301e7ac08a (patch) | |
| tree | 9af244392d41542fae74ceab1be0b8fb473bdd46 /crates/shirabe/src/downloader | |
| parent | 6dcc2125974e350d1844c5ce1bb3562e224f3435 (diff) | |
| download | php-shirabe-a8f115666344abe3b606a4a65595ca301e7ac08a.tar.gz php-shirabe-a8f115666344abe3b606a4a65595ca301e7ac08a.tar.zst php-shirabe-a8f115666344abe3b606a4a65595ca301e7ac08a.zip | |
refactor(process): take cwd as Option<&str> instead of IntoExecCwd
Replace the generic cwd parameter backed by the IntoExecCwd trait with a
concrete Option<&str> across execute/execute_args/execute_tty/execute_async.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader')
| -rw-r--r-- | crates/shirabe/src/downloader/fossil_downloader.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/git_downloader.rs | 114 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/gzip_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/hg_downloader.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/rar_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/svn_downloader.rs | 15 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/xz_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/zip_downloader.rs | 2 |
8 files changed, 76 insertions, 71 deletions
diff --git a/crates/shirabe/src/downloader/fossil_downloader.rs b/crates/shirabe/src/downloader/fossil_downloader.rs index ab98168..26a0987 100644 --- a/crates/shirabe/src/downloader/fossil_downloader.rs +++ b/crates/shirabe/src/downloader/fossil_downloader.rs @@ -43,7 +43,7 @@ impl FossilDownloader { .inner .process .borrow_mut() - .execute(&command, output, cwd)? + .execute(&command, output, cwd.as_deref())? != 0 { return Err(RuntimeException { @@ -271,7 +271,7 @@ impl ChangeReportInterface for FossilDownloader { self.inner.process.borrow_mut().execute_args( &["fossil".to_string(), "changes".to_string()], &mut output, - shirabe_php_shim::realpath(path), + shirabe_php_shim::realpath(path).as_deref(), ); let output = output.trim().to_string(); diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index fa7fd16..a3666d0 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -83,7 +83,7 @@ impl GitDownloader { .inner .process .borrow_mut() - .execute_args(&command, &mut output, Some(path.clone())) + .execute_args(&command, &mut output, Some(&path)) != 0 { return Err(RuntimeException { @@ -179,7 +179,7 @@ impl GitDownloader { if self.inner.process.borrow_mut().execute_args( &command, &mut output, - Some(path.clone()), + Some(&path), ) != 0 { return Err(RuntimeException { @@ -210,7 +210,7 @@ impl GitDownloader { self.inner.process.borrow_mut().execute_args( &["git".to_string(), "fetch".to_string(), "--all".to_string()], &mut output, - Some(path.clone()), + Some(&path), ); // update list of refs after fetching @@ -221,11 +221,12 @@ impl GitDownloader { "-d".to_string(), ]; let mut output = String::new(); - if self.inner.process.borrow_mut().execute_args( - &command, - &mut output, - Some(path.clone()), - ) != 0 + if self + .inner + .process + .borrow_mut() + .execute_args(&command, &mut output, Some(&path)) + != 0 { return Err(RuntimeException { message: format!( @@ -289,7 +290,7 @@ impl GitDownloader { if self.inner.process.borrow_mut().execute_args( &["git".to_string(), "branch".to_string(), "-r".to_string()], &mut output, - Some(path.to_string()), + Some(path), ) == 0 { branches = Some(output); @@ -322,18 +323,19 @@ impl GitDownloader { ]; let mut output = String::new(); - let ok1 = self.inner.process.borrow_mut().execute_args( - &command1, - &mut output, - Some(path.to_string()), - ) == 0; + let ok1 = + self.inner + .process + .borrow_mut() + .execute_args(&command1, &mut output, Some(path)) + == 0; let ok2 = if ok1 { let mut output = String::new(); - self.inner.process.borrow_mut().execute_args( - &command2, - &mut output, - Some(path.to_string()), - ) == 0 + self.inner + .process + .borrow_mut() + .execute_args(&command2, &mut output, Some(path)) + == 0 } else { false }; @@ -381,17 +383,18 @@ impl GitDownloader { ]; let mut output = String::new(); - let ok_command = self.inner.process.borrow_mut().execute_args( - &command, - &mut output, - Some(path.to_string()), - ) == 0; + let ok_command = + self.inner + .process + .borrow_mut() + .execute_args(&command, &mut output, Some(path)) + == 0; let ok_fallback = if !ok_command { let mut output = String::new(); self.inner.process.borrow_mut().execute_args( &fallback_command, &mut output, - Some(path.to_string()), + Some(path), ) == 0 } else { false @@ -401,7 +404,7 @@ impl GitDownloader { self.inner.process.borrow_mut().execute_args( &reset_command, &mut output, - Some(path.to_string()), + Some(path), ) == 0 } else { false @@ -423,18 +426,19 @@ impl GitDownloader { ]; { let mut output = String::new(); - let ok1 = self.inner.process.borrow_mut().execute_args( - &command1, - &mut output, - Some(path.to_string()), - ) == 0; + let ok1 = + self.inner + .process + .borrow_mut() + .execute_args(&command1, &mut output, Some(path)) + == 0; let ok2 = if ok1 { let mut output = String::new(); - self.inner.process.borrow_mut().execute_args( - &command2, - &mut output, - Some(path.to_string()), - ) == 0 + self.inner + .process + .borrow_mut() + .execute_args(&command2, &mut output, Some(path)) + == 0 } else { false }; @@ -492,7 +496,7 @@ impl GitDownloader { url.to_string(), ], &mut output, - Some(path.to_string()), + Some(path), ); self.set_push_url(path, url); } @@ -535,11 +539,10 @@ impl GitDownloader { push_url, ]; let mut ignored_output = String::new(); - self.inner.process.borrow_mut().execute_args( - &cmd, - &mut ignored_output, - Some(path.to_string()), - ); + self.inner + .process + .borrow_mut() + .execute_args(&cmd, &mut ignored_output, Some(path)); } } @@ -551,7 +554,7 @@ impl GitDownloader { if self.inner.process.borrow_mut().execute_args( &["git".to_string(), "clean".to_string(), "-df".to_string()], &mut output, - Some(path.clone()), + Some(&path), ) != 0 { return Err(RuntimeException { @@ -564,7 +567,7 @@ impl GitDownloader { if self.inner.process.borrow_mut().execute_args( &["git".to_string(), "reset".to_string(), "--hard".to_string()], &mut output, - Some(path.clone()), + Some(&path), ) != 0 { return Err(RuntimeException { @@ -591,7 +594,7 @@ impl GitDownloader { "--include-untracked".to_string(), ], &mut output, - Some(path.clone()), + Some(&path), ) != 0 { return Err(RuntimeException { @@ -613,7 +616,7 @@ impl GitDownloader { if self.inner.process.borrow_mut().execute_args( &["git".to_string(), "diff".to_string(), "HEAD".to_string()], &mut output, - Some(path.clone()), + Some(&path), ) != 0 { return Err(RuntimeException { @@ -711,11 +714,12 @@ impl ChangeReportInterface for GitDownloader { "--untracked-files=no".to_string(), ]; let mut output = String::new(); - if self.inner.process.borrow_mut().execute_args( - &command, - &mut output, - Some(path.to_string()), - ) != 0 + if self + .inner + .process + .borrow_mut() + .execute_args(&command, &mut output, Some(path)) + != 0 { return Err(RuntimeException { message: format!( @@ -1061,7 +1065,7 @@ impl VcsDownloader for GitDownloader { format!("{}^{{commit}}", r#ref), ], &mut output, - Some(path.clone()), + Some(&path), ) != 0 { let commands = vec![ @@ -1116,7 +1120,7 @@ impl VcsDownloader for GitDownloader { if self.inner.process.borrow_mut().execute_args( &["git".to_string(), "remote".to_string(), "-v".to_string()], &mut output, - Some(path.clone()), + Some(&path), ) == 0 { let mut origin_match: IndexMap<CaptureKey, String> = IndexMap::new(); @@ -1334,7 +1338,7 @@ impl VcsDownloader for GitDownloader { if self.inner.process.borrow_mut().execute_args( &["git".to_string(), "stash".to_string(), "pop".to_string()], &mut output, - Some(path.clone()), + Some(&path), ) != 0 { return Err(RuntimeException { @@ -1371,7 +1375,7 @@ impl VcsDownloader for GitDownloader { .inner .process .borrow_mut() - .execute_args(&command, &mut output, Some(path.clone())) + .execute_args(&command, &mut output, Some(&path)) != 0 { return Err(RuntimeException { diff --git a/crates/shirabe/src/downloader/gzip_downloader.rs b/crates/shirabe/src/downloader/gzip_downloader.rs index aefc6f9..8146145 100644 --- a/crates/shirabe/src/downloader/gzip_downloader.rs +++ b/crates/shirabe/src/downloader/gzip_downloader.rs @@ -120,7 +120,7 @@ impl ArchiveDownloader for GzipDownloader { .collect(), ), Some(&mut process_output), - (), + None, )? == 0 { return Ok(None); diff --git a/crates/shirabe/src/downloader/hg_downloader.rs b/crates/shirabe/src/downloader/hg_downloader.rs index 16a78a0..650746b 100644 --- a/crates/shirabe/src/downloader/hg_downloader.rs +++ b/crates/shirabe/src/downloader/hg_downloader.rs @@ -114,7 +114,7 @@ impl VcsDownloader for HgDownloader { if self.inner.process.borrow_mut().execute_args( &command, &mut ignored_output, - shirabe_php_shim::realpath(path), + shirabe_php_shim::realpath(path).as_deref(), ) != 0 { return Err(RuntimeException { @@ -201,7 +201,7 @@ impl VcsDownloader for HgDownloader { if self.inner.process.borrow_mut().execute_args( &command, &mut output, - shirabe_php_shim::realpath(path), + shirabe_php_shim::realpath(path).as_deref(), ) != 0 { return Err(RuntimeException { @@ -237,7 +237,7 @@ impl ChangeReportInterface for HgDownloader { self.inner.process.borrow_mut().execute_args( &["hg".to_string(), "st".to_string()], &mut output, - shirabe_php_shim::realpath(path), + shirabe_php_shim::realpath(path).as_deref(), ); let output = output.trim().to_string(); diff --git a/crates/shirabe/src/downloader/rar_downloader.rs b/crates/shirabe/src/downloader/rar_downloader.rs index 29ea491..73d5fdf 100644 --- a/crates/shirabe/src/downloader/rar_downloader.rs +++ b/crates/shirabe/src/downloader/rar_downloader.rs @@ -93,7 +93,7 @@ impl ArchiveDownloader for RarDownloader { .collect(), ), Some(&mut process_output), - (), + None, )? == 0 { return Ok(None); diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index 6aed27a..1a7d81d 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -69,7 +69,7 @@ impl SvnDownloader { if self.inner.process.borrow_mut().execute_args( ["svn", "revert", "-R", "."].map(|s| s.to_string()).as_ref(), &mut output, - Some(path.to_string()), + Some(path), ) != 0 { return Err(RuntimeException { @@ -378,11 +378,12 @@ impl VcsDownloader for SvnDownloader { path.to_string(), ]; let mut output = String::new(); - if self.inner.process.borrow_mut().execute_args( - &command, - &mut output, - Some(path.to_string()), - ) != 0 + if self + .inner + .process + .borrow_mut() + .execute_args(&command, &mut output, Some(path)) + != 0 { return Err(RuntimeException { message: format!( @@ -466,7 +467,7 @@ impl ChangeReportInterface for SvnDownloader { .map(|s| s.to_string()) .as_ref(), &mut output, - Some(path.to_string()), + Some(path), ); Ok(if Preg::is_match("{^ *[^X ] +}m", &output) { diff --git a/crates/shirabe/src/downloader/xz_downloader.rs b/crates/shirabe/src/downloader/xz_downloader.rs index d79f9bc..d7f94c3 100644 --- a/crates/shirabe/src/downloader/xz_downloader.rs +++ b/crates/shirabe/src/downloader/xz_downloader.rs @@ -80,7 +80,7 @@ impl ArchiveDownloader for XzDownloader { .collect(), ), Some(&mut ignored_output), - (), + None, )? == 0 { return Ok(None); diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs index d7508a6..bea2b20 100644 --- a/crates/shirabe/src/downloader/zip_downloader.rs +++ b/crates/shirabe/src/downloader/zip_downloader.rs @@ -132,7 +132,7 @@ impl ZipDownloader { .inner .process .borrow_mut() - .execute_async(&command, ()) + .execute_async(&command, None) .await; match process_result { Ok(mut process) => { |
