pedroborges / kirby-autogit

⬢ Saves every change made via Kirby Panel to a Git repository
149 stars 23 forks source link

Plugin crashes if no repo exists #10

Closed mbernath closed 7 years ago

mbernath commented 8 years ago

When the content folder does not contain a valid Git repo, it crashes.

The reason is in the Autogit class constructor: It executes two commands that should only be executed if there is a valid Git repo. These commands do not catch any Exceptions. Thus the site crashes.

autogit()->setBranch();
autogit()->setUser(site()->user());

Suggested resolution: Move these two lines to autogit.php after the isRepo check just like this:

if (autogit()->isRepo()) {

    autogit()->setBranch();
    autogit()->setUser(site()->user());
...

Background: I use Docker instances to run Kirby for dev & production purposes. For the dev environment I want to disable kirby-autogit features. Therefore the content directory is not a valid git repository.

pedroborges commented 7 years ago

Thanks for pointing that out @mbernath. You have a valid use case and I plan to add an option to disable it entirely.