sponsor-patch: Check if the version of a sync request is mentioned in the bug title.

This commit is contained in:
Benjamin Drung 2011-09-15 13:37:22 +02:00
parent 5942694e6f
commit 663cb5214f
3 changed files with 22 additions and 1 deletions

View File

@ -68,6 +68,10 @@ class BugTask(object):
return "lp:" + self.project + "/" + self.get_series() + "/" + \ return "lp:" + self.project + "/" + self.get_series() + "/" + \
self.package self.package
def get_bug_title(self):
"""Returns the title of the related bug."""
return self.bug_task.bug.title
def get_long_info(self): def get_long_info(self):
return "Bug task: " + str(self.bug_task) + "\n" + \ return "Bug task: " + str(self.bug_task) + "\n" + \
"Package: " + str(self.package) + "\n" + \ "Package: " + str(self.package) + "\n" + \
@ -156,3 +160,7 @@ class BugTask(object):
def is_ubuntu_task(self): def is_ubuntu_task(self):
return self.project == "ubuntu" return self.project == "ubuntu"
def title_contains(self, word):
"""Checks if the bug title contains the given word."""
return word in self.bug_task.bug.title.split(" ")

View File

@ -26,7 +26,7 @@ from devscripts.logger import Logger
from ubuntutools import subprocess from ubuntutools import subprocess
from ubuntutools.harvest import Harvest from ubuntutools.harvest import Harvest
from ubuntutools.question import Question from ubuntutools.question import Question, YesNoQuestion
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing, user_abort from ubuntutools.sponsor_patch.question import ask_for_manual_fixing, user_abort
@ -289,6 +289,18 @@ class SourcePackage(object):
return False return False
return True return True
def check_sync_request_version(self, bug_number, task):
"""Check if the downloaded version of the package is mentioned in the
bug title."""
if not task.title_contains(self._version):
print "Bug #%i title: %s" % (bug_number, task.get_bug_title())
msg = "Is %s %s the version that should be synced" % (self._package,
self._version)
answer = YesNoQuestion().ask(msg, "no")
if answer == "no":
user_abort()
@property @property
def _debdiff_filename(self): def _debdiff_filename(self):
"""Returns the file name of the .debdiff file.""" """Returns the file name of the .debdiff file."""

View File

@ -261,6 +261,7 @@ def sponsor_patch(bug_number, build, builder, edit, keyid, lpinstance, update,
if is_sync(bug) and not edit: if is_sync(bug) and not edit:
successful = True successful = True
source_package.reload_changelog() source_package.reload_changelog()
source_package.check_sync_request_version(bug_number, task)
if build: if build:
dist = UbuntuDistroInfo().devel() dist = UbuntuDistroInfo().devel()
successful = source_package.build(update, dist) successful = source_package.build(update, dist)