sebastian/git-state
PHP library to describe the state of a Git checkout. Retrieve origin URL, current branch and commit hash, and determine whether the working directory is clean or get a git-style status output. Useful for build/test tooling and CI metadata.
Library for describing the state of a Git checkout.
You can add this library as a local, per-project dependency to your project using Composer:
composer require sebastian/git-state
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev sebastian/git-state
test.phpuse SebastianBergmann\GitState\Builder;
$builder = new Builder;
$state = $builder->build();
if ($state === false) {
// Not a Git repository or no origin remote configured
exit(1);
}
print $state->originUrl() . PHP_EOL;
print $state->branch() . PHP_EOL;
print $state->commit() . PHP_EOL;
if ($state->isClean()) {
print 'Working directory is clean' . PHP_EOL;
} else {
print $state->status() . PHP_EOL;
}
github.com:sebastianbergmann/git-state.git
main
ab00820c3757dbd30a8caa185aa4515b98713238
M README.md
?? test.php
How can I help you explore Laravel packages today?