From: Michael Tremer Date: Fri, 27 Oct 2017 15:55:20 +0000 (+0100) Subject: builds: Import bugs from commit tags X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82e2ba5164ef7554718bf02ffa0419bc4f346ebb;p=pbs.git builds: Import bugs from commit tags Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index 5da249b3..2d29beae 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -213,9 +213,6 @@ class Builds(base.Object): # Obsolete all other builds with the same name to track updates. build.obsolete_others() - # Search for possible bug IDs in the commit message. - build.search_for_bugs() - return build def create_from_source_package(self, filename, distro, commit=None, type="release", @@ -240,6 +237,11 @@ class Builds(base.Object): # Create a new build object from the package build = self.create(pkg, type=type, owner=owner, distro=distro) + if commit: + # Import any fixed bugs + for bug in commit.fixed_bugs: + build.add_bug(bug) + # Create all automatic jobs build.create_autojobs(arches=arches) @@ -1043,26 +1045,6 @@ class Build(base.DataObject): if log: self.log("bug_removed", user=user, bug_id=bug_id) - def search_for_bugs(self): - if not self.commit: - return - - pattern = re.compile(r"(bug\s?|#)(\d+)") - - for txt in (self.commit.subject, self.commit.message): - for bug in re.finditer(pattern, txt): - try: - bugid = int(bug.group(2)) - except ValueError: - continue - - # Check if a bug with the given ID exists in BZ. - bug = self.backend.bugzilla.get_bug(bugid) - if not bug: - continue - - self.add_bug(bugid) - def get_bugs(self): bugs = [] for bug_id in self.get_bug_ids(): diff --git a/src/buildservice/sources.py b/src/buildservice/sources.py index 09e6cd7e..50430c56 100644 --- a/src/buildservice/sources.py +++ b/src/buildservice/sources.py @@ -207,7 +207,7 @@ class Commit(base.DataObject): Returns the message without any Git tags """ # Compile regex - r = re.compile("^(%s):" % "|".join(VALID_TAGS), re.IGNORECASE) + r = re.compile("^(%s):?" % "|".join(VALID_TAGS), re.IGNORECASE) message = [] for line in self.body.splitlines(): @@ -252,7 +252,7 @@ class Commit(base.DataObject): raise ValueError("Unknown tag: %s" % tag) # Compile regex - r = re.compile("^%s: (.*)$" % tag, re.IGNORECASE) + r = re.compile("^%s:? (.*)$" % tag, re.IGNORECASE) values = [] for line in self.body.splitlines(): @@ -300,6 +300,13 @@ class Commit(base.DataObject): return self.backend.users.find_maintainers(users) + @property + def fixed_bugs(self): + """ + Returns a list of all fixed bugs + """ + return self.get_tag("Fixes") + @property def date(self): return self.data.date