Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

Auto-Git trigger #18

Open
AlexKucera opened this issue Jul 11, 2017 · 3 comments
Open

Auto-Git trigger #18

AlexKucera opened this issue Jul 11, 2017 · 3 comments

Comments

@AlexKucera
Copy link

Hi Sebastian,

me again. :)

I see that you at least took a look at the Auto-Git plugin. Do you know of a way to make your plugin trigger the Auto-Git routine?

Pedro the developer mentions something that looks to be a simple line of code to make it work. I have just no idea where to put it. :)

Auto Git uses Kirby hooks to detect changes:

kirby()->set('hook', 'panel.page.create', function ($page) {
    autogit()->save('page.create', $page);
});

The save method runs git add -all content/ followed by a git commit -m 'Message goes here'. 
So yes, it would get committed on the next change done via the panel.

Other plugins could call the save method as well. 
Maybe I can make that even easier and more customisable.
@sebsel
Copy link
Owner

sebsel commented Jul 15, 2017

Well, I have seen Auto-Git, but I have not used it myself yet.

I already trigger a hook in /lib/endpoint.php#L302, but it seems that that is insufficient. It's a weird choice of params I chose, so I need to change that.

The solution should be, in your config.php (note the 'micropub'):

kirby()->hook('micropub.page.create', function ($page) {
    autogit()->save('page.create', $page->uri());
});
kirby()->hook('micropub.page.update', function ($page) {
    autogit()->save('page.update', $page->uri());
});

Please note that this does not work yet. I need to make some changes to the Micropub plugin.

Edit: Note to self, I took the code from https://github.com/pedroborges/kirby-autogit/blob/f36e5bcdc2d8da1fc7c56f1a0f9a636e7673129a/lib/hooks.php

@AlexKucera
Copy link
Author

Cool. I have a very crude way involving Cron jobs working right now. But this sounds very promising.

@sebsel
Copy link
Owner

sebsel commented Jul 15, 2017

Just pushed a commit (d3473c4) to fix this. Hope it works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants