aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/git.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-08 03:04:27 +0900
committernsfisis <nsfisis@gmail.com>2026-08-08 03:04:27 +0900
commitda0d38a8e16ebefd59ef5291b5788e6238cc78ba (patch)
treec6a4cb9f2444beeb84b2d30133053867acb46741 /crates/shirabe/src/util/git.rs
parentc0879ab4a02b257cb0bd416dbdfa07784c8e3809 (diff)
downloadphp-shirabe-da0d38a8e16ebefd59ef5291b5788e6238cc78ba.tar.gz
php-shirabe-da0d38a8e16ebefd59ef5291b5788e6238cc78ba.tar.zst
php-shirabe-da0d38a8e16ebefd59ef5291b5788e6238cc78ba.zip
refactor(semver): replace Constraint's OP_*/STR_OP_* with CmpOp
PHP's version_compare takes its operator as a string, so the shim's port did too, and Constraint carried two families of operator constants plus translation tables to convert between the string form and its own int codes. Five copies of those tables had accumulated across Constraint, CompilingMatcher and the plugin value bridge. version_compare now takes a CmpOp, which makes an invalid operator unrepresentable and removes the tables' reason to exist. Constraint stores a CmpOp and keeps only the string parsing its constructor needs; getOperator, compile and CompilingMatcher::match speak CmpOp as well. PHP's OP_* numbering stays observable: a plugin reads the raw integer off the Constraint object over RPC, so get_operator_constant and its new inverse hold that 0..5 mapping. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util/git.rs')
-rw-r--r--crates/shirabe/src/util/git.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs
index 0ee69926..a6f8d79e 100644
--- a/crates/shirabe/src/util/git.rs
+++ b/crates/shirabe/src/util/git.rs
@@ -16,10 +16,10 @@ use crate::util::{AuthHelper, StoreAuth};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache,
- explode, implode, in_array_loose, in_array_strict, is_dir, php_regex, preg_quote, rawurldecode,
- rawurlencode, str_contains, str_ends_with, str_replace_array, strlen, strpos, substr, trim,
- version_compare,
+ CmpOp, InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map,
+ clearstatcache, explode, implode, in_array_loose, in_array_strict, is_dir, php_regex,
+ preg_quote, rawurldecode, rawurlencode, str_contains, str_ends_with, str_replace_array, strlen,
+ strpos, substr, trim, version_compare,
};
use std::sync::Mutex;
@@ -982,7 +982,7 @@ impl Git {
) -> String {
let git_version = Self::get_version(process);
if let Some(v) = git_version
- && version_compare(&v, "2.10.0-rc0", ">=")
+ && version_compare(&v, "2.10.0-rc0", CmpOp::Ge)
{
return " --no-show-signature".to_string();
}
@@ -1010,7 +1010,7 @@ impl Git {
let git_version = Self::get_version(process);
git_version
- .map(|v| version_compare(&v, "2.33.0-rc0", ">="))
+ .map(|v| version_compare(&v, "2.33.0-rc0", CmpOp::Ge))
.unwrap_or(false)
}
@@ -1212,7 +1212,7 @@ impl Git {
// PHP: $process ?? new ProcessExecutor()
let git_version = Self::get_version(process);
if let Some(v) = git_version {
- if version_compare(&v, "2.3.0", ">=") {
+ if version_compare(&v, "2.3.0", CmpOp::Ge) {
// added in git 2.3.0, prevents prompting the user for username/password
if Platform::get_env("GIT_TERMINAL_PROMPT").as_deref() != Some("0") {
Platform::put_env("GIT_TERMINAL_PROMPT", "0");