pedroborges / kirby-autogit

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

Sorting large numbers of pages doesn't always get everything committed to git #32

Closed fitzage closed 6 years ago

fitzage commented 6 years ago

I'm not entirely sure what's going on here, but I went and looked at git status on my server, and there were a bunch of "deleted" items that weren't committed that were basically there because of Kirby renumbering things when I made some changes. Any idea why these aren't getting committed and what I can do about it?

Do I need to manually trigger a hook?

pedroborges commented 6 years ago

I ran into this issue once and ended up hacking Kirby's core since they didn't fix it when I reported the issue: getkirby/panel#1006

See line #788 from kirby/kirby.php, I changed it to:

if(in_array($key, static::$triggered[$pattern]) && $pattern !== 'panel.file.sort') continue;

I can't test this now, so try it out and let me know if that fixes it for you. Please leave a comment on the issue I reported, maybe they will listen this time.

fitzage commented 6 years ago

So according to this, the problem should only exist for files, but I'm having the problem with pages.

What I end up with is apparently the new pages are in git, but when I do git status I have a crapload of deleted pages because of the old sorting numbers.

pedroborges commented 6 years ago

The code responsible for triggering hooks in Kirby checks if a hook has been triggered during a given session and skips it if so. So making an exception for file and page sorting should fix it, can you try this?

if(in_array($key, static::$triggered[$pattern]) && ! in_array($pattern, ['panel.file.sort', 'panel.page.sort'])) continue;