Skip to content
Ian Paul edited this page Aug 15, 2021 · 13 revisions

The focus of flashbake is generating automatic commit messages so you don’t have to provide any information when your changes are committed to git. I will be exploring other ways of using this main capability of flashbake, such as commit hooks to git itself or perhaps as part of an editor plugin.

Right now, the simplest way to run flashbake is with a scheduler, like cron. There is also a usage section that details running flashbake manually.

Using Cron

When run under cron the optional quiet period starts to make sense. For example, say you have a project in ~/my_novel/ that you want to track. Add a cron job like:

*/15 * * * * flashbake ~/my_novel 5 > /dev/null

Cron will then run flashbake every fifteen minutes and commit any changes to hot files in the project that have not been changed in the last 5 minutes. If there have been recent changes, flashbake will pick them up next time cron runs it, assuming the files haven’t been edited within five minutes of that invocation. You can tweak that quiet interval argument to make flashbake more greedy, committing more often, or more cautious, waiting until edits have stopped for a considerable duration. I encourage some experimentation to find what suits you.

You can also completely disable the quiet period behavior by using the value 0 or, as of version 0.19, completely omitting the quiet period argument. Disabling the quiet period means that when cron runs flashbake, all outstanding changes to hot files in a project will be committed.

Troubleshooting Cron

If you are having trouble with running Flashbake from cron it is likely a PATH issue. There are two solutions to this. First, you can try typing the following command to find where Flashbake is installed:

which flashbake

If, for example, the install location is /home/bob/.local/bin/flashbake then your crontab could look like this:

*/15 * * * * /home/bob/.local/bin/flashbake ~/my_novel 5 > /dev/null

The second solution is to add a PATH= line in your crontab file with at least the path to the flashbake directory. Add the below line to the beginning of your crontab assuming flashbake is in the default path after a manual (not via pip) install. Again, you can use the which command as explained above to find flashbake if you are unsure.

PATH=/usr/local/bin/

If neither of those solutions work then try putting the flashbake command in a Bash script, and then have cron execute the Bash script. The simplest way to do this is to first run which flashbake to find where flashbake is installed. If, for example, flashbake is installed in /home/username/.local/bin/flashbake then the bash script would look like this:

#!/bin/sh
/home/username/.local/bin/flashbake /home/username/Documents/my_novel

Save that in your home directory as flashbake.sh or whatever file name you prefer. Then use chmod +x flashbake.sh to make it executable.

Finally, your crontab should look like this to run flashbake every 15 minutes:

*/15 * * * * /home/username/flashbake.sh

flashbake may also have problems finding git. As of version 0.24, it will report clearly if it cannot find git. In that same version, there is also a new option, git_path:, which can be used to tell flashbake exactly where git can be located, if needed.

If cron fails, it will send an email to the root account on your local system by default. This is not always terribly useful. You can add an alternate address for it to email. You must have a local mail transfer agent installed, like postfix or exim, for cron to be able to reach a remote address. If you have such an MTA installed, you can add a line like:

MAILTO=foo@noreply.org

to your crontab and any failure messages will get sent to that address.

Usage

To run Flashbake manually you’d do

flashbake ~/my_novel

If you run

flashbake -c ~/my_novel

flashbake will not commit any changes, rather it will show you the commit message it would generate if run normal. This is useful for checking that you’ve entered the options in the control file correctly and checking the commit message contents. As I work on the plugin system, this will also be useful for plugin authors to check their output.

If you run

flashbake -d ~/my_novel

flashbake will perform a dry run, doing everything but updating git. With the -v/--verbose flag this is helpful for diagnosing problems. The -d/--dryrun switch is available as of 0.20.

The verbose switch simply increases what flashbake reports to the console. I mention it in case you give flashbake a try and want to contact me for help. Capturing that verbose output and including it in help requests will ensure a quicker response and hopefully a faster fix.

I will document new options, here, as they become available and try to note in which version they were added.

Clone this wiki locally