Merge "Add launchpad bug update support to abandon script"

This commit is contained in:
Jenkins 2017-04-20 09:06:05 +00:00 committed by Gerrit Code Review
commit 55be865d9a
3 changed files with 81 additions and 0 deletions

View File

@ -292,6 +292,19 @@ If the bug report is sound, move next:
we rotate, tagging bugs with 'needs-attention' can be useful to quickly
identify what reports need further screening/eyes on.
Check for Bugs with the 'timeout-abandon' tag:
* Search for any bugs with the timeout abandon tag:
`Timeout abandon <https://bugs.launchpad.net/neutron/+bugs?field.tag=timeout-abandon>`_.
This tag indicates that the bug had a patch associated with it that was
automatically abandonded after a timing out with negative feedback.
* For each bug with this tag, determine if the bug is still valid and update
the status accordingly. For example, if another patch fixed the bug, ensure
it's marked as 'Fix Released'. Or, if that was the only patch for the bug and
it's still valid, mark it as 'Confirmed'.
* After ensuring the bug report is in the correct state, remove the
'timeout-abandon' tag.
You are done! Iterate.

View File

@ -36,12 +36,14 @@ else
fi
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function abandon_review {
local gitid=$1
shift
local msg=$@
# echo ssh review.openstack.org gerrit review $gitid --abandon --message \"$msg\"
unassign_and_new_bug $gitid
if [ $DRY_RUN -eq 1 ]; then
echo "Would abandon $gitid"
else
@ -50,6 +52,20 @@ function abandon_review {
fi
}
function unassign_and_new_bug {
# unassign current assignee and set bug to 'new' status
local gitid=$1
cm=$(ssh review.openstack.org "gerrit query $gitid --current-patch-set --format json" | jq .commitMessage)
for closes in $(echo -e $cm | grep -i "closes" | grep -i "bug" | grep -o -E '[0-9]+'); do
if [ $DRY_RUN -eq 1 ]; then
echo "Would unassign and tag 'timeout-abandon' $closes"
else
echo "Attempting to change status of bug $closes to New"
python "$DIR/unassign_bug.py" $closes
fi
done
}
PROJECTS="($(
python - <<EOF
import urllib2

52
tools/unassign_bug.py Normal file
View File

@ -0,0 +1,52 @@
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Unassigns assignee from neutron/network bug, adds message and tag.
If you get the following exception, you need X11 and python-dbus installed:
RuntimeError: No recommended backend was available. Install
the keyrings.alt package if you want to use the non-recommended
backends. See README.rst for details.
"""
import sys
from launchpadlib.launchpad import Launchpad
MSG_BODY = "\
This bug has had a related patch abandoned and has been automatically \
un-assigned due to inactivity. Please re-assign yourself if you are \
continuing work or adjust the state as appropriate if it is no longer valid."
def unassign(bug_num):
launchpad = Launchpad.login_with('neutron', 'production')
b = launchpad.bugs[bug_num]
for task in b.bug_tasks:
if ('neutron' not in task.bug_target_name and
'network' not in task.bug_target_name):
# try not to interfere with non-neutron projects too much
continue
task.assignee = None
if task.status == "In Progress":
task.status = 'New'
task.lp_save()
b.tags = b.tags + ['timeout-abandon']
b.newMessage(content=MSG_BODY, subject='auto-abandon-script')
b.lp_save()
if __name__ == '__main__':
unassign(int(sys.argv[1]))