diff options
Diffstat (limited to 'crates/shirabe/src')
| -rw-r--r-- | crates/shirabe/src/command/fund_command.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/command/update_command.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/binary_installer.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/package/version/version_guesser.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/svn_driver.rs | 12 | ||||
| -rw-r--r-- | crates/shirabe/src/util/hg.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/platform.rs | 4 |
7 files changed, 17 insertions, 21 deletions
diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs index 7f2dd24c..109943d6 100644 --- a/crates/shirabe/src/command/fund_command.rs +++ b/crates/shirabe/src/command/fund_command.rs @@ -67,7 +67,7 @@ impl FundCommand { php_regex!(r"{^https://github.com/([^/]+)$}"), &url, ) - && let Some(sponsor) = matches.into_iter().nth(1) + && let Some(sponsor) = matches.into_iter().nth(1).flatten() { url = format!("https://github.com/sponsors/{}", sponsor); } diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index 38a79e30..2eca6db7 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -466,10 +466,8 @@ impl Command for UpdateCommand { let Some(matches) = matches else { continue; }; - let constraint = parser.parse_constraints(&format!( - "~{}", - matches.get(1).cloned().unwrap_or_default() - ))?; + let constraint = parser + .parse_constraints(&format!("~{}", matches[1].clone().unwrap_or_default()))?; if let Some(existing) = temporary_constraints.get(&package.get_name()) { temporary_constraints.insert( package.get_name(), diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index d5ece82f..606e943f 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -328,10 +328,10 @@ impl BinaryInstaller { &bin_contents, ) { // carry over the existing shebang if present, otherwise add our own - let proxy_code = if m.get(1).is_none() { + let proxy_code = if m[1].is_none() { "#!/usr/bin/env php".to_string() } else { - trim(m.get(1).map(|s| s.as_str()).unwrap_or(""), None) + trim(m[1].as_deref().unwrap_or(""), None) }; let bin_path_exported = self .filesystem @@ -377,7 +377,7 @@ impl BinaryInstaller { $data = str_replace('__FILE__', var_export($this->realpath, true), $data);" .to_string(); } - if trim(m.first().map(|s| s.as_str()).unwrap_or(""), None) != "<?php" { + if trim(m[0].as_deref().unwrap_or(""), None) != "<?php" { stream_hint = " using a stream wrapper to prevent the shebang from being output on PHP<8\n *" .to_string(); diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs index 4f46919e..4b5187f2 100644 --- a/crates/shirabe/src/package/version/version_guesser.rs +++ b/crates/shirabe/src/package/version/version_guesser.rs @@ -704,9 +704,9 @@ impl VersionGuesser { ); if let Some(matches) = Preg::is_match_with_indexed_captures(&url_pattern, &output) { - let m1 = matches.get(1).cloned().unwrap_or_default(); - let m2 = matches.get(2).cloned(); - let m3 = matches.get(3).cloned(); + let m1 = matches[1].clone().unwrap_or_default(); + let m2 = matches[2].clone(); + let m3 = matches[3].clone(); if let Some(m2) = m2.as_ref() && let Some(m3) = m3.as_ref() && (branches_path == *m2 || tags_path == *m2) diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 297e8f33..db8c43f0 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -260,10 +260,10 @@ impl SvnDriver { let (path, rev) = if let Some(m) = Preg::is_match_with_indexed_captures(php_regex!(r"{^(.+?)(@\d+)?/$}"), &identifier) { - if m.get(2).is_some() { + if m[2].is_some() { ( - m.get(1).cloned().unwrap_or_default(), - m.get(2).cloned().unwrap_or_default(), + m[1].clone().unwrap_or_default(), + m[2].clone().unwrap_or_default(), ) } else { (identifier.clone(), String::new()) @@ -300,10 +300,10 @@ impl SvnDriver { let (path, rev) = if let Some(m) = Preg::is_match_with_indexed_captures(php_regex!(r"{^(.+?)(@\d+)?/$}"), &identifier) { - if m.get(2).is_some() { + if m[2].is_some() { ( - m.get(1).cloned().unwrap_or_default(), - m.get(2).cloned().unwrap_or_default(), + m[1].clone().unwrap_or_default(), + m[2].clone().unwrap_or_default(), ) } else { (identifier.clone(), String::new()) diff --git a/crates/shirabe/src/util/hg.rs b/crates/shirabe/src/util/hg.rs index 8570af6d..d9e58623 100644 --- a/crates/shirabe/src/util/hg.rs +++ b/crates/shirabe/src/util/hg.rs @@ -158,7 +158,7 @@ impl Hg { &output, ) { - return matches.into_iter().nth(1); + return matches.into_iter().nth(1).flatten(); } None }) diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 21ad869c..629854b6 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -95,14 +95,12 @@ impl Platform { // Regex pattern compatibility: // The original pattern uses a conditional subpattern to make the trailing `%` required // only for the `%VAR%` form. The Rust regex crate does not support conditionals, so the - // two forms are written as an explicit alternation: `$VAR` or `%VAR%`. The branch that did - // not participate is reported as an empty string, which `\w+` can never capture. + // two forms are written as an explicit alternation: `$VAR` or `%VAR%`. Preg::replace_callback( php_regex!(r"#^(?:\$(?P<dvar>\w+)|%(?P<pvar>\w+)%)(?P<path>.*)#"), |matches: &PregMatchedGroups| -> String { let var = matches .get(&CaptureKey::ByName("dvar".to_string())) - .filter(|dvar| !dvar.is_empty()) .or_else(|| matches.get(&CaptureKey::ByName("pvar".to_string()))) .map(|s| s.as_str()) .unwrap_or(""); |
