定制 kellegous/codeowners 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kellegous/codeowners

最新稳定版本:1.1.0

Composer 安装命令:

composer require kellegous/codeowners

包简介

Parsing and matching of Github's CODEOWNERS file format

README 文档

README

This provides a parser and a set of matchers for the CODEOWNERS file format.

Installation

via Composer

composer require kellegous/codeowners

Usage

SimpleMatcher

The SimpleMatcher is a straight-forward implementation of a RuleMatcher that can find the relevant pattern for a file path in O(N) time relative to the number of rules in the CODEOWNERS file.

$owners = Owners::fromFile('.github/CODEOWNERS');
$matcher = new SimpleMatcher($owners->getRules());
$rule = $matcher->match($relative_path);

AutomataMatcher

The AutomataMatcher is a more complex implementation of a RuleMatcher that requires a bit more memory that the SimpleMatcher but is able to do matching in O(log N) time relative to the number of rules in the CODEOWNERS file.

$owners = Owners::fromFile('.github/CODEOWNERS');
$matcher = AutomataMatcher::build($owners->getRules());
$rule = $matcher->match($relative_path);

What does the AutomataMatcher do?

Each of the patterns in a CODEOWNERS rule is a simplified regular expression and, thus, it could be represented as a fininte automata. In fact, the SimpleMatcher turns each of the patterns into a regular expression and then iteratively matches the path against those regular expressions. In other words, the SimpleMatcher executes the finite automata of each rule independently. The AutomataMatcher, on the other hand, combines all of the patterns into a single finite automata. For example, here is the state machine for Github's exmaple CODEOWNERS.

Automata for CODEOWNERS.example

The image was rendered with the following command:

bin/render-nfa tests/CODEOWNERS.example | dot -Tpng -o tests/CODEOWNERS.example.png

Acknowledgements

The code in SimpleMatcher that converts patterns to regular expressions owes a debt of gratitude to https://github.com/hmarr/codeowners.

Author(s)

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-21