Improving Gerrit + commit-log automation.

I've reworked a few items here, so I will describe them in as much a
linear fashion as possible. Keep in mind that one of the primary goals
for these changes is to allow us to "trigger more magic from Gerrit".
And it is to that end that I've implemented these changes.

In find_bugs(), I've tightened-up the regular expression being used so
that it will parse-out any prefixes associated with the bug reference.
I've tested the regular expression against the most common bug
references that I've seen in commit logs, as well as against the
styles described in our documentation. The sources that I've drawn
from are:

    https://etherpad.openstack.org/drive-automation-from-commitmsg
    https://wiki.openstack.org/wiki/GitCommitMessages
    https://wiki.openstack.org/wiki/Gerrit_Workflow

Moreover, I'm using re.finditer() which allows for more direct
access to the text that was matched. Lastly, I've tried to keep the
expression as flexible as possible so that it will match even if the
developer references the bug in a funky way.

In order to keep the prefix and lp_task associated with each other,
I've created a class called "Task" which is simply an interface to
determine what sort of automation needs to take place for the given
bugtask. This being the case, I've taken the liberty of renaming a few
variables to make this more clear.

In "Task", a basic level of processing is performed on the prefix to
determine what changes need to be made on launchpad. A method called
needs_change() returns a boolean indicating if the supplied argument
is a change which needs to be made.

Lastly, yet most importantly for this bug fix, process_bugtsk() is
utilizing needs_change(), as mentioned above, to ensure that the
bugtask's status is not erroneously changed in the case of a bug fix
which spans multiple commits.

Closes-Bug: 1018013
Change-Id: Ibd84d3c6edcf104afe3211fb55ea531efa92d20e
1 file changed