Allow user to override sanity checks (LP: #896733).

This commit is contained in:
Benjamin Drung 2011-12-21 22:09:53 +01:00
parent e1e13bbfdc
commit bbfbfd8956
3 changed files with 26 additions and 10 deletions

1
debian/changelog vendored
View File

@ -5,6 +5,7 @@ ubuntu-dev-tools (0.138) UNRELEASED; urgency=low
- Use syncpackage instead of subscribing ubuntu-archive for sync requests, - Use syncpackage instead of subscribing ubuntu-archive for sync requests,
because syncpackage supports sponsorship now. because syncpackage supports sponsorship now.
- Check if the sponsored bug is marked as duplicate (LP: #896733). - Check if the sponsored bug is marked as duplicate (LP: #896733).
- Allow user to override sanity checks (LP: #896733).
[ Stefano Rivera ] [ Stefano Rivera ]
* Correct reference to qemu-user-static in pbuilder-dist.1 (Closes: #651999) * Correct reference to qemu-user-static in pbuilder-dist.1 (Closes: #651999)

View File

@ -17,14 +17,31 @@
import sys import sys
from ubuntutools.question import YesNoQuestion from ubuntutools.question import Question, YesNoQuestion
def ask_for_ignoring_or_fixing():
"""Ask the user to resolve an issue manually or ignore it.
Returns false if the user want to fix the issue and returns true if the user
want to ignore the issue.
"""
question = Question(["yes", "ignore", "no"])
answer = question.ask("Do you want to resolve this issue manually", "yes")
if answer == "no":
user_abort()
return answer == "ignore"
def ask_for_manual_fixing(): def ask_for_manual_fixing():
"""Ask the user to resolve an issue manually."""
answer = YesNoQuestion().ask("Do you want to resolve this issue manually", answer = YesNoQuestion().ask("Do you want to resolve this issue manually",
"yes") "yes")
if answer == "no": if answer == "no":
user_abort() user_abort()
def user_abort(): def user_abort():
"""Print abort and quit the program."""
print "User abort." print "User abort."
sys.exit(2) sys.exit(2)

View File

@ -28,7 +28,9 @@ from ubuntutools import subprocess
from ubuntutools.harvest import Harvest from ubuntutools.harvest import Harvest
from ubuntutools.question import Question, YesNoQuestion 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_ignoring_or_fixing,
ask_for_manual_fixing,
user_abort)
def _get_series(launchpad): def _get_series(launchpad):
"""Returns a tuple with the development and list of supported series.""" """Returns a tuple with the development and list of supported series."""
@ -270,16 +272,14 @@ class SourcePackage(object):
Logger.error(("%s is not an allowed series. It needs to be one " Logger.error(("%s is not an allowed series. It needs to be one "
"of %s.") % (self._changelog.distributions, "of %s.") % (self._changelog.distributions,
", ".join(allowed))) ", ".join(allowed)))
ask_for_manual_fixing() return ask_for_ignoring_or_fixing()
return False
elif upload and upload.startswith("ppa/"): elif upload and upload.startswith("ppa/"):
allowed = supported_series + [devel_series] allowed = supported_series + [devel_series]
if self._changelog.distributions not in allowed: if self._changelog.distributions not in allowed:
Logger.error(("%s is not an allowed series. It needs to be one " Logger.error(("%s is not an allowed series. It needs to be one "
"of %s.") % (self._changelog.distributions, "of %s.") % (self._changelog.distributions,
", ".join(allowed))) ", ".join(allowed)))
ask_for_manual_fixing() return ask_for_ignoring_or_fixing()
return False
return True return True
def check_version(self, previous_version): def check_version(self, previous_version):
@ -292,8 +292,7 @@ class SourcePackage(object):
if self._version <= previous_version: if self._version <= previous_version:
Logger.error("The version %s is not greater than the already " Logger.error("The version %s is not greater than the already "
"available %s.", self._version, previous_version) "available %s.", self._version, previous_version)
ask_for_manual_fixing() return ask_for_ignoring_or_fixing()
return False
return True return True
def check_sync_request_version(self, bug_number, task): def check_sync_request_version(self, bug_number, task):
@ -363,8 +362,7 @@ class SourcePackage(object):
if lp_bug.id not in fixed_bugs: if lp_bug.id not in fixed_bugs:
Logger.error("Launchpad bug #%i is not closed by new version." % \ Logger.error("Launchpad bug #%i is not closed by new version." % \
(lp_bug.id)) (lp_bug.id))
ask_for_manual_fixing() return ask_for_ignoring_or_fixing()
return False
return True return True
def _print_logs(self): def _print_logs(self):