From 790602d4d849c0643b8e172265d3d2eb1bd3e78e Mon Sep 17 00:00:00 2001 From: "ityaozm@gmail.com" Date: Tue, 22 Oct 2024 11:01:34 +0800 Subject: [PATCH] fix(app/Commands): fix CommitCommand message parsing - Update message parsing logic in CommitCommand - Trim leading and trailing whitespace - Remove control characters from the message --- app/Commands/CommitCommand.php | 1 + composer.lock | 248 ++++++++++++++++++++--------- tests/Datasets/InvalidMessages.php | 2 +- 3 files changed, 171 insertions(+), 80 deletions(-) diff --git a/app/Commands/CommitCommand.php b/app/Commands/CommitCommand.php index b59b1ea..f8b32b8 100644 --- a/app/Commands/CommitCommand.php +++ b/app/Commands/CommitCommand.php @@ -354,6 +354,7 @@ private function tryFixMessage(string $message): string // '/,\s*,/' => ',', // 连续的逗号 // '/[\x00-\x1F\x7F-\x9F]/mu' => '', // 控制字符 '/[[:cntrl:]]/mu' => '', // 控制字符 + '/\s+/' => ' ', // 连续的空格 ])->reduce(static function (Stringable $message, string $replace, string $pattern): Stringable { return $message->replaceMatches($pattern, $replace); }, $message); diff --git a/composer.lock b/composer.lock index dc12eb6..6f24d41 100644 --- a/composer.lock +++ b/composer.lock @@ -266,6 +266,42 @@ ], "time": "2023-10-01T12:35:29+00:00" }, + { + "name": "container-interop/container-interop", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "shasum": "" + }, + "require": { + "psr/container": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "homepage": "https://github.com/container-interop/container-interop", + "support": { + "issues": "https://github.com/container-interop/container-interop/issues", + "source": "https://github.com/container-interop/container-interop/tree/master" + }, + "abandoned": "psr/container", + "time": "2017-02-14T19:40:03+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.10", @@ -950,16 +986,16 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { @@ -1013,7 +1049,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.3" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -1029,7 +1065,7 @@ "type": "tidelift" } ], - "time": "2024-07-18T10:29:17+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", @@ -2204,49 +2240,51 @@ }, { "name": "laminas/laminas-servicemanager", - "version": "3.22.1", + "version": "3.7.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "de98d297d4743956a0558a6d71616979ff779328" + "reference": "2b0aee477fdbd3191af7c302b93dbc5fda0626f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/de98d297d4743956a0558a6d71616979ff779328", - "reference": "de98d297d4743956a0558a6d71616979ff779328", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/2b0aee477fdbd3191af7c302b93dbc5fda0626f4", + "reference": "2b0aee477fdbd3191af7c302b93dbc5fda0626f4", "shasum": "" }, "require": { - "laminas/laminas-stdlib": "^3.17", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "container-interop/container-interop": "^1.2", + "laminas/laminas-stdlib": "^3.2.1", + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^7.3 || ~8.0.0", "psr/container": "^1.0" }, "conflict": { - "ext-psr": "*", - "laminas/laminas-code": "<4.10.0", - "zendframework/zend-code": "<3.3.1", - "zendframework/zend-servicemanager": "*" + "laminas/laminas-code": "<3.3.1", + "zendframework/zend-code": "<3.3.1" }, "provide": { + "container-interop/container-interop-implementation": "^1.2", "psr/container-implementation": "^1.0" }, "replace": { - "container-interop/container-interop": "^1.2.0" + "zendframework/zend-servicemanager": "^3.4.0" }, "require-dev": { - "composer/package-versions-deprecated": "^1.11.99.5", - "friendsofphp/proxy-manager-lts": "^1.0.14", - "laminas/laminas-code": "^4.10.0", - "laminas/laminas-coding-standard": "~2.5.0", - "laminas/laminas-container-config-test": "^0.8", - "mikey179/vfsstream": "^1.6.11", - "phpbench/phpbench": "^1.2.9", - "phpunit/phpunit": "^10.4", - "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.8.0" + "composer/package-versions-deprecated": "^1.0", + "laminas/laminas-coding-standard": "~2.2.0", + "laminas/laminas-container-config-test": "^0.3", + "laminas/laminas-dependency-plugin": "^2.1.2", + "mikey179/vfsstream": "^1.6.8", + "ocramius/proxy-manager": "^2.2.3", + "phpbench/phpbench": "^1.0.4", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.4", + "psalm/plugin-phpunit": "^0.16.1", + "vimeo/psalm": "^4.8" }, "suggest": { - "friendsofphp/proxy-manager-lts": "ProxyManager ^2.1.1 to handle lazy initialization of services" + "ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services" }, "bin": [ "bin/generate-deps-for-config-factory", @@ -2254,9 +2292,6 @@ ], "type": "library", "autoload": { - "files": [ - "src/autoload.php" - ], "psr-4": { "Laminas\\ServiceManager\\": "src/" } @@ -2290,34 +2325,34 @@ "type": "community_bridge" } ], - "time": "2023-10-24T11:19:47+00:00" + "time": "2021-07-24T19:33:07+00:00" }, { "name": "laminas/laminas-stdlib", - "version": "3.19.0", + "version": "3.11.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "6a192dd0882b514e45506f533b833b623b78fff3" + "reference": "aad7d2b11ba0069ba0d9b40f6dde3c2fa664b57f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/6a192dd0882b514e45506f533b833b623b78fff3", - "reference": "6a192dd0882b514e45506f533b833b623b78fff3", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/aad7d2b11ba0069ba0d9b40f6dde3c2fa664b57f", + "reference": "aad7d2b11ba0069ba0d9b40f6dde3c2fa664b57f", "shasum": "" }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, "conflict": { "zendframework/zend-stdlib": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "^2.5", - "phpbench/phpbench": "^1.2.15", - "phpunit/phpunit": "^10.5.8", - "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.20.0" + "laminas/laminas-coding-standard": "~2.3.0", + "phpbench/phpbench": "^1.0", + "phpunit/phpunit": "^9.3.7", + "psalm/plugin-phpunit": "^0.17.0", + "vimeo/psalm": "^4.7" }, "type": "library", "autoload": { @@ -2349,35 +2384,33 @@ "type": "community_bridge" } ], - "time": "2024-01-19T12:39:49+00:00" + "time": "2022-07-27T12:28:58+00:00" }, { "name": "laminas/laminas-text", - "version": "2.11.0", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-text.git", - "reference": "d799f3ccb3547e9e6ab313447138bae7009c7cc7" + "reference": "8879e75d03e09b0d6787e6680cfa255afd4645a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-text/zipball/d799f3ccb3547e9e6ab313447138bae7009c7cc7", - "reference": "d799f3ccb3547e9e6ab313447138bae7009c7cc7", + "url": "https://api.github.com/repos/laminas/laminas-text/zipball/8879e75d03e09b0d6787e6680cfa255afd4645a7", + "reference": "8879e75d03e09b0d6787e6680cfa255afd4645a7", "shasum": "" }, "require": { - "laminas/laminas-servicemanager": "^3.22.0", - "laminas/laminas-stdlib": "^3.7.1", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + "laminas/laminas-servicemanager": "^3.4", + "laminas/laminas-stdlib": "^3.6", + "php": "^7.3 || ~8.0.0 || ~8.1.0" }, "conflict": { "zendframework/zend-text": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "~2.5.0", - "phpunit/phpunit": "^9.5", - "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.1" + "laminas/laminas-coding-standard": "~1.0.0", + "phpunit/phpunit": "^9.3" }, "type": "library", "autoload": { @@ -2409,7 +2442,70 @@ "type": "community_bridge" } ], - "time": "2023-11-07T16:45:45+00:00" + "time": "2021-09-02T16:50:53+00:00" + }, + { + "name": "laminas/laminas-zendframework-bridge", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-zendframework-bridge.git", + "reference": "88bf037259869891afce6504cacc4f8a07b24d0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/88bf037259869891afce6504cacc4f8a07b24d0f", + "reference": "88bf037259869891afce6504cacc4f8a07b24d0f", + "shasum": "" + }, + "require": { + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "psalm/plugin-phpunit": "^0.15.1", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.6" + }, + "type": "library", + "extra": { + "laminas": { + "module": "Laminas\\ZendFrameworkBridge" + } + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\ZendFrameworkBridge\\": "src//" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Alias legacy ZF class names to Laminas Project equivalents.", + "keywords": [ + "ZendFramework", + "autoloading", + "laminas", + "zf" + ], + "support": { + "forum": "https://discourse.laminas.dev/", + "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", + "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", + "source": "https://github.com/laminas/laminas-zendframework-bridge" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "abandoned": true, + "time": "2021-12-21T14:34:37+00:00" }, { "name": "laravel-zero/foundation", @@ -2551,29 +2647,28 @@ }, { "name": "laravel-zero/phar-updater", - "version": "v1.4.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/laravel-zero/phar-updater.git", - "reference": "700fafcde3b59e261f896b1bdb0f5657f5d46f99" + "reference": "ac583f0983f91df9ca18c31ef6fd44dd51820495" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel-zero/phar-updater/zipball/700fafcde3b59e261f896b1bdb0f5657f5d46f99", - "reference": "700fafcde3b59e261f896b1bdb0f5657f5d46f99", + "url": "https://api.github.com/repos/laravel-zero/phar-updater/zipball/ac583f0983f91df9ca18c31ef6fd44dd51820495", + "reference": "ac583f0983f91df9ca18c31ef6fd44dd51820495", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^7.3|^8.0" }, "conflict": { "padraic/phar-updater": "*" }, "require-dev": { "ext-json": "*", - "laravel/pint": "^1.12", - "phpstan/phpstan": "^1.10.32", - "phpunit/phpunit": "^9.6.11" + "phpstan/phpstan": "^0.12.85", + "phpunit/phpunit": "^9.4" }, "type": "library", "autoload": { @@ -2590,11 +2685,6 @@ "name": "Padraic Brady", "email": "padraic.brady@gmail.com", "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Owen Voke", - "email": "development@voke.dev", - "homepage": "https://voke.dev" } ], "description": "A thing to make PHAR self-updating easy and secure.", @@ -2606,9 +2696,9 @@ ], "support": { "issues": "https://github.com/laravel-zero/phar-updater/issues", - "source": "https://github.com/laravel-zero/phar-updater/tree/v1.4.0" + "source": "https://github.com/laravel-zero/phar-updater/tree/v1.1.1" }, - "time": "2023-09-01T10:40:10+00:00" + "time": "2021-08-03T08:29:40+00:00" }, { "name": "league/flysystem", @@ -4381,20 +4471,20 @@ }, { "name": "psr/container", - "version": "1.1.2", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=7.4.0" + "php": ">=7.2.0" }, "type": "library", "autoload": { @@ -4423,9 +4513,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/1.1.1" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "psr/event-dispatcher", @@ -8057,7 +8147,7 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -8065,6 +8155,6 @@ "ext-curl": "*", "ext-json": "*" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/tests/Datasets/InvalidMessages.php b/tests/Datasets/InvalidMessages.php index 9104f1f..8bb40c1 100644 --- a/tests/Datasets/InvalidMessages.php +++ b/tests/Datasets/InvalidMessages.php @@ -40,7 +40,7 @@ # Explanation: { - "subject": "fix(app/Commands): fix CommitCommand message parsing", + "subject": "fix(app/Commands): fix CommitCommand message parsing", "body": "- Update message parsing logic in CommitCommand\n- Trim leading and trailing whitespace\n- Remove control characters from the message" }