From 718c2f6c44987ce4ccc488b9313d41d4bceb7475 Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Thu, 15 Feb 2018 23:52:31 +0100 Subject: [PATCH] reviewers: fixed logic with wildcard match for branches. --- rhodecode/model/db.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py index b096d67d..0dd1c781 100644 --- 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) + '$') + 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 = ( - bool(source_branch_regex.search(source_branch)) and - bool(target_branch_regex.search(target_branch)) - ) + branch_matches = source_branch_match and target_branch_match files_matches = True if self.file_pattern != '*':