For commit messages, process all bugs being closed.
The standard web hook that marks bugs pending when a commit message mentions them as being closed does not appear to work correctly for more than two bugs. I believe it ignores any bugs mentioned in the middle of the list, i.e. all those not the first or last position.
I recently I encountered the issue for a second time. As result of
the following commit, Bug#971597
was not marked pending
(but the other
two bugs were):
https://salsa.debian.org/lintian/lintian/-/commit/fb98c17998000073ee1dbc6f9726691b5183f23e
For this commit, I split the scanning of bug numbers from the text
matching for closing details after being advised on Freenode:#ruby
that the match
function would be more appropriate for our use case.
Unfortunately I was unable, like the original author of this Ruby
module, to get multiple matches to work correctly with match
alone.
The web hook probably runs thousands of times a day. I hope the resulting regular expression is tight enough to be widely deployed.
When running your own checks, please make sure these changes react gracefully when there are no matches. This commit is untested, and my Ruby skills are limited.
I merely verified the regular expressions in the interactive Ruby interpreter with commands like this:
"Merge subindices. (Closes: Bug#970750, #971597, #972567)".match(/\(Closes:(?:,|\s|(?:Bug)?#?\d{4,8})*\)/) do |match| match[0].scan(/\d+/) end
Please note that, in a departure from previous code, this commit permits the hash symbol which is so often placed in front of bug numbers to be absent. It tripped me up a few times when typing hastily, so I made the change here.
As for the hash, it may make sense to go easy. When placed at the beginning of a line, some software (most notably Git) misidentifies the bug reference as a comment and removes it even though it was likely a meaningful part of the commit message.