diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-05 04:45:11 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-05 04:45:11 +0900 |
| commit | d0edb5b7ac3456f99c2f2576e8992cc12d60574a (patch) | |
| tree | b69546366676c06e1c8fabddb592c202436a92b2 /crates/shirabe/src/repository/vcs/forgejo_driver.rs | |
| parent | 53800ab77565de1c16fb8a95e047eba1cb3a160c (diff) | |
| download | php-shirabe-d0edb5b7ac3456f99c2f2576e8992cc12d60574a.tar.gz php-shirabe-d0edb5b7ac3456f99c2f2576e8992cc12d60574a.tar.zst php-shirabe-d0edb5b7ac3456f99c2f2576e8992cc12d60574a.zip | |
refactor(json): model JsonFile encode/write options as a typed struct
Replace the i64 bitmask + encode_with_indent split with a JsonEncodeOptions
struct (Default = JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE,
default indent). encode/write each get a default form plus an explicit
encode_with_options/write_with_options variant, mirroring PHP's optional
$options argument. write_with_options always encodes with self.indent, matching
PHP write().
Also reconcile call sites with the PHP sources: most ported sites passed 0 where
Composer omits the argument (= default flags), so JsonManipulator/ShowCommand and
JsonConfigSource now use the default options; only ComposerRepository and Locker
genuinely pass 0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/vcs/forgejo_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/forgejo_driver.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index d5c4a89..ca7e9dd 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -13,6 +13,7 @@ use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; @@ -341,17 +342,17 @@ impl ForgejoDriver { )?; if self.inner.should_cache(identifier) { if let Some(ref composer_map) = c { - // TODO(phase-b): JsonFile::encode_with_options does not exist; use encode - let encoded = JsonFile::encode( + let encoded = JsonFile::encode_with_options( &PhpMixed::Array( composer_map .iter() .map(|(k, v)| (k.clone(), Box::new(v.clone()))) .collect(), ), - (shirabe_php_shim::JSON_UNESCAPED_UNICODE - | shirabe_php_shim::JSON_UNESCAPED_SLASHES) - as i64, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ); self.inner .cache |
