aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe/src/command/repository_command.rs2
-rw-r--r--crates/shirabe/src/config.rs6
-rw-r--r--crates/shirabe/src/dependency_resolver/rule.rs2
-rw-r--r--crates/shirabe/tests/command/repository_command_test.rs10
4 files changed, 8 insertions, 12 deletions
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index 4cbe08c..c8d99a5 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -296,7 +296,7 @@ impl Command for RepositoryCommand {
}));
}
let arg1_str = arg1.as_deref().unwrap();
- let repo_config: PhpMixed = if Preg::is_match(r"^\s*\{", arg1_str) {
+ let repo_config: PhpMixed = if Preg::is_match(r"{^\s*\{}", arg1_str) {
JsonFile::parse_json(Some(arg1_str), None)?
} else {
if arg2.is_none() {
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs
index 68cad87..b3eb47d 100644
--- a/crates/shirabe/src/config.rs
+++ b/crates/shirabe/src/config.rs
@@ -451,6 +451,12 @@ impl Config {
.collect();
let new_repos_map: IndexMap<String, PhpMixed> = match &repositories_section {
PhpMixed::Array(m) => m.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
+ // A JSON array decodes to a List; in PHP it is an array with integer keys.
+ PhpMixed::List(items) => items
+ .iter()
+ .enumerate()
+ .map(|(i, v)| (i.to_string(), v.clone()))
+ .collect(),
_ => IndexMap::new(),
};
let new_repos: IndexMap<String, PhpMixed> = new_repos_map.into_iter().rev().collect();
diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs
index ef39513..bc6fd95 100644
--- a/crates/shirabe/src/dependency_resolver/rule.rs
+++ b/crates/shirabe/src/dependency_resolver/rule.rs
@@ -23,11 +23,11 @@ use crate::dependency_resolver::RuleSet;
use crate::package::AliasPackage;
use crate::package::BasePackage;
use crate::package::BasePackageHandle;
-use crate::repository::RepositoryInterface;
use crate::package::Link;
use crate::package::PackageInterface;
use crate::package::version::VersionParser;
use crate::repository::PlatformRepository;
+use crate::repository::RepositoryInterface;
use crate::repository::RepositorySet;
#[derive(Debug)]
diff --git a/crates/shirabe/tests/command/repository_command_test.rs b/crates/shirabe/tests/command/repository_command_test.rs
index 0cad288..1d104e7 100644
--- a/crates/shirabe/tests/command/repository_command_test.rs
+++ b/crates/shirabe/tests/command/repository_command_test.rs
@@ -41,7 +41,6 @@ fn test_list_with_no_repositories() {
#[test]
#[serial]
-#[ignore = "src bug: config.rs Config::merge only reads repositories when PhpMixed::Array (JSON object); list-form repositories decode to PhpMixed::List and are dropped (crates/shirabe/src/config.rs:452-455), so list-form repos are not listed and output falls back to the default packagist repo"]
fn test_list_with_repositories_as_list() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({
@@ -120,7 +119,6 @@ fn test_list_with_repositories_as_assoc() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_add_repository_with_type_and_url() {
let tear_down = init_temp_composer(Some(&serde_json::json!({})), None, None, true);
@@ -156,7 +154,6 @@ fn test_add_repository_with_type_and_url() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_add_repository_with_json() {
let tear_down = init_temp_composer(Some(&serde_json::json!({})), None, None, true);
@@ -351,7 +348,6 @@ fn run_set_and_get_url_list_case(name: &str, index: usize, new_url: &str) {
#[test]
#[serial]
-#[ignore = "src bug: config.rs Config::merge only reads repositories when PhpMixed::Array (JSON object); list-form repositories decode to PhpMixed::List and are dropped (crates/shirabe/src/config.rs:452-455), so get-url panics with 'There is no first repository defined'"]
fn test_set_and_get_url_in_repository_list() {
// change first of three
run_set_and_get_url_list_case("first", 0, "https://new.example.org");
@@ -428,7 +424,6 @@ fn test_invalid_arg_combination_throws() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_prepend_repository_by_name_list_to_assoc() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({
@@ -469,7 +464,6 @@ fn test_prepend_repository_by_name_list_to_assoc() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_append_repository_by_name_list_to_assoc() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({
@@ -511,7 +505,6 @@ fn test_append_repository_by_name_list_to_assoc() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_prepend_repository_assoc_with_packagist_disabled() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({
@@ -553,7 +546,6 @@ fn test_prepend_repository_assoc_with_packagist_disabled() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_append_repository_assoc_with_packagist_disabled() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({
@@ -596,7 +588,6 @@ fn test_append_repository_assoc_with_packagist_disabled() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_add_before_and_after_by_name() {
// Start with two repos as named-list and a disabled packagist boolean
let tear_down = init_temp_composer(
@@ -671,7 +662,6 @@ fn test_add_before_and_after_by_name() {
#[test]
#[serial]
-#[ignore = "src bug: repository_command.rs:299 passes the un-delimited regex r\"^\\s*\\{\" to Preg::is_match (PHP source uses the delimited '{^\\s*\\{}'); compile_php_pattern rejects it, panicking at shirabe-php-shim/src/preg.rs:180 'invalid regex: unterminated regex pattern: ^\\s*\\{' on every add action"]
fn test_add_same_name_replaces_existing() {
let tear_down = init_temp_composer(Some(&serde_json::json!({})), None, None, true);