tjvb / githash
从您的项目中获取当前的 git 哈希值。
1.3.0
2023-11-24 09:40 UTC
Requires
- php: ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
Requires (Dev)
- fakerphp/faker: ^1.15
- infection/infection: ^0.25.0
- phpmd/phpmd: ^2.10
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- symfony/process: ^5.3
Suggests
- symfony/process: Used rather than `shell_exec` if available (tested with ^5.3).
This package is auto-updated.
Last update: 2024-09-15 09:56:27 UTC
README
此包旨在提供一个有用的选项,用于从当前提交中获取哈希值。
使用方法
try {
$retriever = Retriever::getWithFactory(GitHashFinderFactory::withDefaultFinders());
echo $retriever->getHash($path)->hash() . PHP_EOL;
} catch (GitHashException $exception) {
echo 'Failed to get the hash ' . $exception->getMessage() . PHP_EOL;
}
示例
有关如何使用此包的示例,请参阅 docs/examples。
安装
您可以通过执行以下命令使用 composer 安装此包:composer require tjvb/githash
。
不同的 HashFinders
该包提供了 3 种不同的 GitHashFinder,它们各有优缺点。
GitHashFinder | 要求 | 优点 | 缺点 |
---|---|---|---|
GitProcessCommandHashFinder | 需要 symfony/process 包和 git 可执行文件。 | 此包使用 symfony/process 包执行 git 命令以获取良好的反馈。 | 您需要安装此包并确保 git 命令可用。 |
GitShellExecCommandHashFinder | 需要 shell_exec PHP 函数和 git 可执行文件。 | 此包执行 git 命令。 | 您需要确保 shell_exec 和 git 命令可用。 |
GitFileSystemHashFinder | 一个分支。 | 它读取 git 文件,不需要 git 可执行文件。 | 存储库需要有一个分支,它不适用于分离头。 |
Laravel 包
如果您使用 Laravel,可以使用 tjvb/laravel-githash,此包可以将哈希值添加到您的日志文件中,并提供一个 blade 组件来显示哈希值。
变更日志
我们在 CHANGELOG 中(尝试)记录了所有变更,请阅读以获取更多信息。
贡献
欢迎您贡献力量,请参阅 CONTRIBUTING。
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。