Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Gitlib Laravel Package

gitonomy/gitlib

Gitonomy Gitlib is a PHP library for interacting with Git repositories programmatically. Read commits, trees, branches, tags and diffs; run Git commands via a clean API and work with local repos from your apps, tools, or CI scripts.

View on GitHub
Deep Wiki
Context7

Hooks

It's possible to define custom hooks on any repository with git. Those hooks are located in the .git/hooks folder.

Those files need to be executable. For convenience, gitlib will set them to 777.

With gitlib, you can manage hooks over a repository using the Hooks object.

To access it from a repository, use the getHooks method on a Repository object:

$hooks = $repository->getHooks();

Reading hooks

To read the content of a hook, use the get method like this:

$content = $hooks->get('pre-receive'); // returns a string

If the hook does not exist, an exception will be thrown (InvalidArgumentException).

You can test if a hook is present using the method has:

$hooks->has('pre-receive'); // a boolean indicating presence

Inserting hooks

You can modify a hook in two different ways: creating a new file or using a symlink.

To create the hook using a symlink:

$hooks->setSymlink('pre-receive', '/path/to/file-to-link');

If the hook already exist, a LogicException will be thrown. If an error occured during symlink creation, a RuntimeException will be thrown.

If you want to directly create a new file in hooks directory, use the method set. This method will create a new file, put content in it and make it executable:

$content = <<<HOOK
#!/bin/bash
echo "Push is disabled"
exit 1

HOOK;

// this hook will reject every push

$hooks->set('pre-receive', $content);

If the hook already exists, a LogicException will be thrown.

Removing hooks

To remove a hook from a repository, use the function remove:

$hooks->remove('pre-receive');
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui