Git-commit-and-push-content

Hey,

I made a Plugin to version control the content folder using git. Using the kirby panel hooks everything that can be hooked into will be staged, committed and pushed to its own git repository.

The git history will look like this:

sort(page): team/max-mustermann by kirby-panel-username 136b20af
upload(file): team/max-mustermann/max-mustermann.jpg by kirby-panel-username ede54f13
update(page): team/max-mustermann by kirby-panel-username d79daee5
create(page): team/max-mustermann by kirby-panel-username 853992b3

Let me know what you think, contributions are more than welcome!

Going further:
As the commit messages are written as they are you can use conventional-changelog (grunt version) to automatically generate a CHANGELOG.md.

7 Likes

Looking forward to testing this :grinning: Been thinking of creating such a plugin myself for a while …

1 Like

I’m also looking forward to test this… since am still not pleased with my current deploy strategy. This thread from a while ago also didn’t brought much light to the issue:

http://forum.getkirby.com/t/how-to-best-organize-files-folders-repos-the-deploy-strategy/489

1 Like

Great! Thanks, I will give it a try.

Hi
Thanks for your plugin!
I followed the instructions and I don’t seem to get it to work…
It seems it’s a problem when $repo = Git::open(’…/content’); is called since it never comes back.
I see some Exceptions can be thrown in the code but I don’t know exactly how do you they are displayed in the panel even when debug is set to true. They seem to be suppressed somehow.
Do you have some tip on how to debug your plugin?
Any hint is appreciated :slightly_smiling:
Best regards
Vlad

You can open the Dev Tools in your Browser and select the Network-Panel. When you hit “Save” in the Kirby Panel there will be a new Request if you click on it and check the Response there will be the error message you are looking for.

1 Like

Hi Thanks for the response. I’ve tried your suggestion but I don’t see any errors popping up there only some html being returned with a 200 status. So the exceptions are not being returned from git.php. I think you are talking about the echo messages in your code directly.
Here more background on what’s happening:

Hi Lukas,

Thanks for the advice!
We have tried to used the suggested plugin but encounter some difficulties with the commits:

https://github.com/kbjr/Git.php/issues/41

Have you seen something like that?
Also the hook triggered doesn’t seems to be correct one, sort instead of update.

One reason could be that your webserver and therefore PHP runs as a different user than on your shell. You should be able to fix this by running the commands directly in the repository and leaving out the --global option so that the values are saved to the content repository.

Thanks for the suggestions, but I’m running apache locally under my login account. The same that Terminal is using. And the content repository as already the information.
Very strange indeed.

Does the panel.file.move hook exists?
If so… It’s not in the docs.

Anyway, I can’t get this work… and it doesn’t throw any errors… sigh.

I’ve thought that changing line 32 of helper.php would do it… nope:

$repo = Git::open('..'. DS .'content');

Any insights on how to debug this?

That hook is named panel.file.rename.

Does it work when using a different repo for the content folder?

In my tests nothing happens…

I’m having some trouble getting this set up; I managed to follow along so far:

  • Separating out content and the rest into two repositories
  • Installing the plugin (it’s in site/plugins/git-commit-and-push-content/)
  • I added this option to my config.php: c::set('gcapc-commit',true);

Did I miss any essential steps? Anything not in the readme I should be aware of?
Git is working on my server, I can manually commit, push and pull my content / site from and to github…

Make sure you have a Git.php-Folder inside the git-commit-and-push-content folder that isn’t empty - (which is a submobule of this Plugin that can be found here: https://github.com/kbjr/Git.php).

You might want to enable the Push and Pull option aswell, so set gcapc-push and gcapc-pull to true.

Thanks Pascal, both are installed and present on the server. I’ve added push and pull options. However, I haven’t been able to get it to work, manually committing and pushing the changes in the content folder to github via SSH does work. You’ve mentioned in previous posts that errors should show up in the Network pannel when using Dev Tools. When I save using panel, I get a XHR with status code 200, and some json is returned, I don’t see any errors coming from the plugin, which makes this a bit hard to debug. Do you have any suggestions as to what I might try?

Thanks again for helping out!

I just pushed a new Version (1.1.1) where some stuff got refactored, can you try it again with the newsest version? And could you give me the Git Commands you are using when you commit and push manually on the server?

Hi Pascal, I’m afraid I’m still running into problems, I’m hoping you can spare some time to have a look. I’ve tried to simplify by just working with a vanilla kirby installation.

I’ve set up some public repositories to allow you to have a look at what might be wrong. Both can be found here:


gcapc-test contains a vanilla kirby installation (2.2.3), and I followed your readme to my best abilities. the content for this kirby installation is in gcapc-test-content. As far as I can determine your 1.1.1 update and Git.php are installed succesfully from github.

Currently when running this installation with php on the commandline, (OSX 10.11.4) it returns the following error:
/ - parse error, expecting `’)’’ in /Users/username/Development/02_Github_Public/gcapc-test/site/plugins/git-commit-and-push-content/helpers.php on line 14

I’m a bit stumped as for what might be wrong, because that line seems fine to me…

Ok, I moved some code around in helpers.php and now I have commits appearing on github.

I changed:

public function __construct($repoPath = __DIR__ . "/../../../content")
    {
        $this->repoPath = $repoPath;
        $this->branch = c::get('gcapc-branch', 'master');
    }


public function __construct()
    {
        $this->repoPath = __DIR__ . "/../../../content";
        $this->branch = c::get('gcapc-branch', 'master');
    }

And things are starting to work now, the only thing I have to look further at is why page content updates are appearing as sorts in the repository…

^ fixed in 2.3.0 beta, so it works like a charm…

It might be obviouse for some but the plugin doesn’t work when git is not correctly configured for the user running the php process. Unfortunately the plugin fails silently and doesn’t catch that error.