#660 [frontend] webhooks: match real package sub-dir
Closed 5 years ago by praiskup. Opened 5 years ago by praiskup.
Unknown source webhook-package-subdir  into  master

@@ -1,6 +1,8 @@

  import json

  import re

  

+ from os.path import normpath

+ 

  from sqlalchemy import bindparam, Integer

  from sqlalchemy.sql import true, text

  
@@ -193,10 +195,16 @@

  

      @classmethod

      def path_belong_to_package(cls, package, file_path):

-         data = package.source_json_dict

+         package_subdir = normpath(data.get('subdirectory', ''))

+         if package_subdir == '.': # no filter

+             return True

+ 

+         # remove leading/trailing slashes (if any),

+         # and append trailing slash to match subdirs only

+         package_subdir = package_subdir.strip('/') + '/'

+ 

          norm_file_path = file_path.strip('./')

-         package_subdir = data.get('subdirectory') or ''

-         return norm_file_path.startswith(package_subdir.strip('./'))

+         return norm_file_path.startswith(package_subdir)

  

      @classmethod

      def add(cls, user, copr_dir, package_name, source_type=helpers.BuildSourceEnum("unset"), source_json=json.dumps({})):

Previously, change in 'mailman3-hyperkitty' sub-directory would
trigger a rebuild of package with subdir=='mailman3', too.

Fixes: rhbz#1699245

rebased onto 910015c

5 years ago

Obsoleted by #659 in the end.

Pull-Request has been closed by praiskup

5 years ago
Metadata