Closed efoken closed 6 years ago
By default, the commands are the standard Git ones. You are free to override these.
Check out https://github.com/statamic/spock/blob/master/DOCUMENTATION.md#custom-commands
class YourServiceProvider extends ServiceProvider
{
public function boot()
{
app('spock')->setCommands(function ($spock) {
$e = $spock->event();
$user = $spock->user();
foreach ($e->affectedPaths() as $path) {
$commands[] = "git add {$path}";
}
$commands[] = vsprintf('git -c user.name="%s %s" -c user.email="%s"', [
$user->get('first_name'),
$user->get('last_name'),
$user->email()
]);
// Use the event to create the commit message.
// eg. "Statamic\Events\Data\DataSaved" becomes "Data saved"
$class = (new \ReflectionClass($e))->getShortName();
$message = ucfirst(str_replace('_', ' ', snake_case($class)));
$commands[] = sprintf('commit -m "%s', $message);
return $commands;
});
}
}
Wow cool, didn't know that 😃 Thanks!
Just updated to Spock 2.0.1, but I'm missing the possibility to have a custom commit command, like I had in Spock 1: