From 663cb5214f7d9795760792c73e923c6777c08173 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Thu, 15 Sep 2011 13:37:22 +0200 Subject: [PATCH] sponsor-patch: Check if the version of a sync request is mentioned in the bug title. --- ubuntutools/sponsor_patch/bugtask.py | 8 ++++++++ ubuntutools/sponsor_patch/source_package.py | 14 +++++++++++++- ubuntutools/sponsor_patch/sponsor_patch.py | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ubuntutools/sponsor_patch/bugtask.py b/ubuntutools/sponsor_patch/bugtask.py index 8f8d821..639a0dd 100644 --- a/ubuntutools/sponsor_patch/bugtask.py +++ b/ubuntutools/sponsor_patch/bugtask.py @@ -68,6 +68,10 @@ class BugTask(object): return "lp:" + self.project + "/" + self.get_series() + "/" + \ 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): return "Bug task: " + str(self.bug_task) + "\n" + \ "Package: " + str(self.package) + "\n" + \ @@ -156,3 +160,7 @@ class BugTask(object): def is_ubuntu_task(self): 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(" ") diff --git a/ubuntutools/sponsor_patch/source_package.py b/ubuntutools/sponsor_patch/source_package.py index 34203ad..b910aff 100644 --- a/ubuntutools/sponsor_patch/source_package.py +++ b/ubuntutools/sponsor_patch/source_package.py @@ -26,7 +26,7 @@ from devscripts.logger import Logger from ubuntutools import subprocess 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 @@ -289,6 +289,18 @@ class SourcePackage(object): return False 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 def _debdiff_filename(self): """Returns the file name of the .debdiff file.""" diff --git a/ubuntutools/sponsor_patch/sponsor_patch.py b/ubuntutools/sponsor_patch/sponsor_patch.py index cc404cf..cae3bd1 100644 --- a/ubuntutools/sponsor_patch/sponsor_patch.py +++ b/ubuntutools/sponsor_patch/sponsor_patch.py @@ -261,6 +261,7 @@ def sponsor_patch(bug_number, build, builder, edit, keyid, lpinstance, update, if is_sync(bug) and not edit: successful = True source_package.reload_changelog() + source_package.check_sync_request_version(bug_number, task) if build: dist = UbuntuDistroInfo().devel() successful = source_package.build(update, dist)