# HG changeset patch # User Marcin Kuzminski # Date 2018-02-15 22:52:31 # Node ID db47ef3446df925c97075f5c1b27107450cce990 # Parent 5b07455ae3559ff24393cd1180bc19ccbb2255a6 reviewers: fixed logic with wildcard match for branches. diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -4224,7 +4224,8 @@ class RepoReviewRule(Base, BaseModel): """ Check if this review rule matches a branch/files in a pull request - :param branch: branch name for the commit + :param source_branch: source branch name for the commit + :param target_branch: target branch name for the commit :param files_changed: list of file paths changed in the pull request """ @@ -4234,15 +4235,20 @@ class RepoReviewRule(Base, BaseModel): branch_matches = True if source_branch or target_branch: - source_branch_regex = re.compile( - '^' + glob2re(self.source_branch_pattern) + '$') - target_branch_regex = re.compile( - '^' + glob2re(self.target_branch_pattern) + '$') - - branch_matches = ( - bool(source_branch_regex.search(source_branch)) and - bool(target_branch_regex.search(target_branch)) - ) + if self.source_branch_pattern == '*': + source_branch_match = True + else: + source_branch_regex = re.compile( + '^' + glob2re(self.source_branch_pattern) + '$') + source_branch_match = bool(source_branch_regex.search(source_branch)) + if self.target_branch_pattern == '*': + target_branch_match = True + else: + target_branch_regex = re.compile( + '^' + glob2re(self.target_branch_pattern) + '$') + target_branch_match = bool(target_branch_regex.search(target_branch)) + + branch_matches = source_branch_match and target_branch_match files_matches = True if self.file_pattern != '*':