Node.js and adding a Git commit after each edit

I’m running TiddlyWiki with node.js and would like to have the following functionality: When I save a tiddler (regardless if it’s new or edited) or delete a tiddler, I’d like to automatically commit the .tid file in a git repository with a commit message consisting of the the title and the action (Add/Update/Delete). The goal is to have a revision history of each page in a git repo, not necessarily integrated into TiddlyWiki

I’m unsure where to start

  • Listen to events that are fired after the files was saved to the file system
  • Implement it as a separate saver plugin
  • Write a syncadaptor module that wraps the filesystem sync adaptor
  • Do it independently from TiddlyWiki as a cron job and shell script that processes the output of git status. As a newcomer to TiddlyWiki this seems the “easiest” option to me, but would have the drawback of missing individual edits.

Do you have some pointers for me how I could best “hook” into the save/delete filesystem events?

This is a good question, and on my list of action-items for my server updates (but it’s aways down from the real-time work). I’ll post here if I find anything related.

Depending on your scripting ability it seems like this is something you could do without involving changes to tiddlywiki specific tools and that you might find useful in other situations involving changes to files.

For example, I’ve written scripts that used fswatch to watch directory hierarchies for changes and then used fselect with some logic based on what it returns to sync fiesystem changes to remote systems via rsync. You could readily make git status and commit commands be part of your logic to add or commit changes to the repo.