sub bug_format_comment {
my ($self, $args) = @_;
# This replaces every occurrence of the word "foo" with the word
# "bar"
my $regexes = $args->{'regexes'};
# And this links every occurrence of the word "bar" to example.com,
# but it won't affect "foo"s that have already been turned into "bar"
# above (because each regex is run in order, and later regexes don't modify
# earlier matches, due to some cleverness in Bugzilla's internals).
#
# For example, the phrase "foo bar" would become:
# bar <a href="http://example.com/bar">bar</a>
my $commit_match = qr/\bcommit(:*)\s(:*)(\s*)([0-9a-z]{5,})\b/;
push(@$regexes, { match => $commit_match, replace => \&_replace_commit });
my $review_match = qr/^review(:*)\s(:*)(\s*)([0-9]{4,})$/;
push(@$regexes, { match => $review_match, replace => \&_replace_review });
}
# Used by bug_format_comment--see its code for an explanation.
sub _replace_commit {
my $args = shift;
my @value = $args->{matches};
# $match is the first parentheses match in the $bar_match regex
# in bug-format_comment.pl. We get up to 10 regex matches as
# arguments to this function.
my $match = $args->{matches}->[0];
# Remember, you have to HTML-escape any data that you are returning!
$match = html_quote($match);
return qq{<a href="http://cgit.scilab.org/scilab/commit/?id=">match $match</a>};
};