aklump/gitignore

一个小型库,用于匹配 gitignore 风格(glob)模式。

0.0.3 2024-02-16 23:18 UTC

This package is auto-updated.

Last update: 2024-09-17 00:36:18 UTC


README

一个小型库,允许您处理 .gitignore(glob)模式

测试 .gitignore 模式

$pattern = new \AKlump\GitIgnore\Pattern('foo/**/*.php');
$pattern->matches('foo/bar/baz/lorem.php') === TRUE;

转换为正则表达式

$pattern = new \AKlump\GitIgnore\Pattern('settings*.php');
$pattern->toRegex() === '#^settings[^/]*\.php/?$#';

检查字符串是否包含模式

\AKlump\GitIgnore\Analyzer::containsPattern('foo/**') === TRUE
\AKlump\GitIgnore\Analyzer::containsPattern('foo/bar') === FALSE

已知问题

尚未支持所有 特殊字符