Don't fail if the regex doesn't match.

pull/1/head
Simon Quigley 6 years ago
parent 605e65df66
commit e1a859fc5e

@ -225,26 +225,28 @@ def commithook():
if lpname: if lpname:
# https://help.launchpad.net/Code/Git#Linking_to_bugs # https://help.launchpad.net/Code/Git#Linking_to_bugs
regexp = re.compile(r"lp:\s+\#\d+(?:,\s*\#\d+)*") regexp = re.compile(r"lp:\s+\#\d+(?:,\s*\#\d+)*")
lpbugs = regexp.search(commitmessage.lower()).group(0).strip("lp: ").replace("#", "") regexpsearch = regexp.search(commitmessage.lower())
for bug in lpbugs.split(", "): if regexpsearch:
goodtask = None lpbugs = regexpsearch.group(0).strip("lp: ").replace("#", "")
lbug = lp.load("/bugs/"+str(bug).strip()) for bug in lpbugs.split(", "):
bug = lbug goodtask = None
for task in bug.bug_tasks: lbug = lp.load("/bugs/"+str(bug).strip())
for rel in cursupportedrels: bug = lbug
if lpname + " (Ubuntu " + rel + ")" in task.bug_target_display_name: for task in bug.bug_tasks:
goodtask = task for rel in cursupportedrels:
break if lpname + " (Ubuntu " + rel + ")" in task.bug_target_display_name:
if not goodtask: goodtask = task
if lpname + " (Ubuntu)" in task.bug_target_display_name: break
goodtask = task if not goodtask:
if goodtask: if lpname + " (Ubuntu)" in task.bug_target_display_name:
message = bugmessage goodtask = task
message = message.replace("LINK", website + "/" + phidquery["name"]) if goodtask:
message = message.replace("COMMITMESSAGE", commitmessage) message = bugmessage
bug.newMessage(content=message) message = message.replace("LINK", website + "/" + phidquery["name"])
goodtask.status = "Fix Committed" message = message.replace("COMMITMESSAGE", commitmessage)
goodtask.lp_save() bug.newMessage(content=message)
goodtask.status = "Fix Committed"
goodtask.lp_save()
return "OK" return "OK"

Loading…
Cancel
Save