Hi there,
I'm trying to write a small IkiWiki plugin that would set a default commit message when the user submits an edit with an empty "comment about this change" field.
At the moment I managed to make this work at the form level using formbuilder hook, so the UI side is handled.
However, what I really want is to enforce this at the request/commit level, even if the field is cleared manually and submitted empty.
In other words, I'm looking for the proper hook or stage in IkiWiki where the final commit message is assembled and can be modified/validated reliably, rather than only manipulating the HTML form.
Thanks.
#!/usr/bin/perl
package IkiWiki::Plugin::defaultcommit;
use warnings;
use strict;
use IkiWiki 3.00;
use Data::Dumper;
sub import {
hook(type => "formbuilder_setup", id => "defaultcommit", call => \&formbuilder_setup);
hook(type => "editcontent", id => "defaultcommit", call => \&editcontent);
hook(type => "getsetup", id => "defaultcommit", call => \&getsetup);
}
sub getsetup {
return {
plugin => {
safe => 1,
rebuild => 0,
section => "web",
},
defaultcommit_message => {
type => "string",
example => "web edit",
description => "Default commit message used when the edit comment is empty.",
safe => 1,
rebuild => 0,
},
};
}
sub formbuilder_setup {
my %params = @_;
my $form = $params{form};
$form->field(
name => "editmessage",
value => "web edit",
) unless defined $form->field("editmessage");
}
sub editcontent {
my %params = @_;
my $cgi = $params{cgi};
my $name = "message";
my $c = $cgi->param($name);
if (!defined($c) || $c =~ /^\s*$/) {
$cgi->param($name, "web edit");
}
return $params{content};
}
1;
Interesting problem! Presuming you are using git, the section of the git plugin you would want to influence is in sub rcs_commit_helper.
It might be possible to do this by writing a separate plugin and using the RCS plugin hooks. I'm not sure exactly how that would interact with the Git plugin also registering those hooks. You might have to wrap some, or all, of the hooks, passing through to the Git plugin. You'd check and set the 'message' field of
@paramsbefore calling the Git plugin implementation of the relevant hooks.Another approach would be to modify the Git plugin and carry the modified version in your libdir. However you would then have to track updates to the upstream Git plugin if/when you updated IkiWiki.
I'd certainly consider a patch for this functionality in IkiWiki itself. In theory, a solution which worked for any VCS backend would be ideal (perhaps we need another hook), but that might be a much harder change. I'd be surprised if we had many non-git users. — Jon, 2026-01-22