timoschinkel / codeowners
用于GitHub、Gitlab和Bitbucket的代码所有者文件的解析器和匹配器。
2.2.2
2024-07-11 13:51 UTC
Requires
- php: ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.4
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^5.23
README
Code Owners 允许您解析 代码所有者文件,并将结果应用于各种不同的结果集,从代码覆盖率到静态分析结果。
代码所有者文件由GitHub、Gitlab 和 Bitbucket 支持。
安装
使用 Composer 进行安装
composer require timoschinkel/codeowners
用法
解析 CODEOWNERS
文件
<?php use CodeOwners\Parser; use CodeOwners\PatternMatcher; try { $patterns = (new Parser())->parseFile($filename); $pattern = (new PatternMatcher(...$patterns))->match($filename); } catch (\CodeOwners\Exception\UnableToParseException $exception) { // unable to read or parse file } catch (\CodeOwners\Exception\NoMatchFoundException $exception) { // no match found }
或者,也可以直接解析字符串
<?php use CodeOwners\Parser; use CodeOwners\PatternMatcher; try { $patterns = (new Parser())->parseString($contents); $pattern = (new PatternMatcher(...$patterns))->match($filename); } catch (\CodeOwners\Exception\UnableToParseException $exception) { // unable to read or parse file } catch (\CodeOwners\Exception\NoMatchFoundException $exception) { // no match found }
已知限制
目前库不支持文件路径中的空格。