diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-27 14:41:41 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-27 14:41:41 +0900 |
| commit | e5657c7709fcb4ee0761cc0b5ae1ad1a26d1ad9a (patch) | |
| tree | b56d588bd4ad7bd72370af03471f8b2f3600ad00 /crates/shirabe/src | |
| parent | 2e4a3cf59df1bc85b0f626f598a5d45bcae8d77a (diff) | |
| download | php-shirabe-e5657c7709fcb4ee0761cc0b5ae1ad1a26d1ad9a.tar.gz php-shirabe-e5657c7709fcb4ee0761cc0b5ae1ad1a26d1ad9a.tar.zst php-shirabe-e5657c7709fcb4ee0761cc0b5ae1ad1a26d1ad9a.zip | |
fix(command/show): match PHP null/isset semantics in package output
Three porting mismatches caused show/info output to diverge from PHP:
- "not found" hint appended " in /composer.json" whenever the
working-dir key existed; PHP uses isset(), which is false for the
null default. Now only appended when the value is non-null.
- printPackages and generatePackageTree inserted "" for a missing
description instead of null, so isset() rendered a spurious trailing
space (and JSON emitted "" instead of null). Both now preserve null.
Un-ignores the eight rendering-gap tests these fix (plus one already
passing), and rewrites the remaining ignore reasons to name the real
blocker (package categorization, --no-dev filtering, RefCell borrow,
installer resolution) instead of a stale generic message.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
| -rw-r--r-- | crates/shirabe/src/command/show_command.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index fa9c3d9..c52e0bf 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -659,13 +659,10 @@ impl Command for ShowCommand { if input.borrow().get_option("locked")?.as_bool() == Some(true) { hint.push_str(" in lock file"); } - if options.contains_key("working-dir") { + if let Some(working_dir) = options.get("working-dir").filter(|v| !v.is_null()) { hint.push_str(&format!( " in {}/composer.json", - options - .get("working-dir") - .and_then(|v| v.as_string()) - .unwrap_or("") + working_dir.as_string().unwrap_or("") )); } if PlatformRepository::is_platform_package(pf) @@ -1200,7 +1197,10 @@ impl Command for ShowCommand { if write_description && let Some(c) = package.as_complete() { package_view_data.insert( "description".to_string(), - PhpMixed::String(c.get_description().unwrap_or_default()), + match c.get_description() { + Some(d) => PhpMixed::String(d), + None => PhpMixed::Null, + }, ); } if write_path { @@ -2524,12 +2524,13 @@ impl ShowCommand { ); tree.insert( "description".to_string(), - PhpMixed::String( - package - .as_complete() - .map(|c| c.get_description().unwrap_or_default()) - .unwrap_or_default(), - ), + match package.as_complete() { + Some(c) => match c.get_description() { + Some(d) => PhpMixed::String(d), + None => PhpMixed::Null, + }, + None => PhpMixed::String(String::new()), + }, ); if !children.is_empty() { |
