]> git.ipfire.org Git - pbs.git/commitdiff
builds: Import bugs from commit tags
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Oct 2017 15:55:20 +0000 (16:55 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Oct 2017 15:55:20 +0000 (16:55 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/buildservice/sources.py

index 5da249b37d31943a9e94f468f9e8534e306f188f..2d29beae1a0158b726ff46a7388a22d093a18b83 100644 (file)
@@ -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():
index 09e6cd7e6ef73e3b331902b617f30edf37095c22..50430c56514f456000ffbcde92314083b2849030 100644 (file)
@@ -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