Closed ghost closed 7 years ago
That's not a bug. Auto Git is only triggered when Kirby hooks are fired and that only happens when changes are made via the panel.
But you can call it manually from anywhere in your code with:
autogit()->save('page.update', $page->uri());
That will create a commit with the message: Updated page {uri}.
Alternatively you can add a custom message by using the autogit.translation
option:
// site/config.php
c::set('autogit.translation', [
'site.update' => 'Changed site options',
'page.create' => 'Created page %s',
'page.update' => 'Updated page %s',
'page.delete' => 'Deleted page %s',
'page.sort' => 'Sorted page %s',
'page.hide' => 'Hid page %s',
'page.move' => 'Moved page %1$s to %2$s',
+ 'page.comment' => 'Comment added to page %s',
'file.upload' => 'Uploaded file %s',
'file.replace' => 'Replaced file %s',
'file.rename' => 'Renamed file %s',
'file.update' => 'Updated file %s',
'file.sort' => 'Sorted file %s',
'file.delete' => 'Deleted file %s',
]);
And then you can use the new key when calling Auto Git after your logic to save the comments:
autogit()->save('page.comment', $page->uri());
Thanks, that is working like a charm!
Assuming I have the following code in one of my controllers that might get executed from time to time:
This would change the file according to my needs but it won't invoke an automatic commit by AutoGit. Is there a way to manually create a commit with AutoGit or is this an unwanted bug?