Show More
@@ -4221,7 +4221,7 b' class RepoReviewRule(Base, BaseModel):' | |||
|
4221 | 4221 | rule_users = relationship('RepoReviewRuleUser') |
|
4222 | 4222 | rule_user_groups = relationship('RepoReviewRuleUserGroup') |
|
4223 | 4223 | |
|
4224 |
def _validate_ |
|
|
4224 | def _validate_pattern(self, value): | |
|
4225 | 4225 | re.compile('^' + glob2re(value) + '$') |
|
4226 | 4226 | |
|
4227 | 4227 | @hybrid_property |
@@ -4230,7 +4230,7 b' class RepoReviewRule(Base, BaseModel):' | |||
|
4230 | 4230 | |
|
4231 | 4231 | @source_branch_pattern.setter |
|
4232 | 4232 | def source_branch_pattern(self, value): |
|
4233 |
self._validate_ |
|
|
4233 | self._validate_pattern(value) | |
|
4234 | 4234 | self._branch_pattern = value or '*' |
|
4235 | 4235 | |
|
4236 | 4236 | @hybrid_property |
@@ -4239,7 +4239,7 b' class RepoReviewRule(Base, BaseModel):' | |||
|
4239 | 4239 | |
|
4240 | 4240 | @target_branch_pattern.setter |
|
4241 | 4241 | def target_branch_pattern(self, value): |
|
4242 |
self._validate_ |
|
|
4242 | self._validate_pattern(value) | |
|
4243 | 4243 | self._target_branch_pattern = value or '*' |
|
4244 | 4244 | |
|
4245 | 4245 | @hybrid_property |
@@ -4248,7 +4248,7 b' class RepoReviewRule(Base, BaseModel):' | |||
|
4248 | 4248 | |
|
4249 | 4249 | @file_pattern.setter |
|
4250 | 4250 | def file_pattern(self, value): |
|
4251 |
self._validate_ |
|
|
4251 | self._validate_pattern(value) | |
|
4252 | 4252 | self._file_pattern = value or '*' |
|
4253 | 4253 | |
|
4254 | 4254 | def matches(self, source_branch, target_branch, files_changed): |
@@ -4269,14 +4269,20 b' class RepoReviewRule(Base, BaseModel):' | |||
|
4269 | 4269 | if self.source_branch_pattern == '*': |
|
4270 | 4270 | source_branch_match = True |
|
4271 | 4271 | else: |
|
4272 | source_branch_regex = re.compile( | |
|
4273 |
|
|
|
4272 | if self.source_branch_pattern.startswith('re:'): | |
|
4273 | source_pattern = self.source_branch_pattern[3:] | |
|
4274 | else: | |
|
4275 | source_pattern = '^' + glob2re(self.source_branch_pattern) + '$' | |
|
4276 | source_branch_regex = re.compile(source_pattern) | |
|
4274 | 4277 | source_branch_match = bool(source_branch_regex.search(source_branch)) |
|
4275 | 4278 | if self.target_branch_pattern == '*': |
|
4276 | 4279 | target_branch_match = True |
|
4277 | 4280 | else: |
|
4278 | target_branch_regex = re.compile( | |
|
4279 |
|
|
|
4281 | if self.target_branch_pattern.startswith('re:'): | |
|
4282 | target_pattern = self.target_branch_pattern[3:] | |
|
4283 | else: | |
|
4284 | target_pattern = '^' + glob2re(self.target_branch_pattern) + '$' | |
|
4285 | target_branch_regex = re.compile(target_pattern) | |
|
4280 | 4286 | target_branch_match = bool(target_branch_regex.search(target_branch)) |
|
4281 | 4287 | |
|
4282 | 4288 | branch_matches = source_branch_match and target_branch_match |
@@ -4284,7 +4290,11 b' class RepoReviewRule(Base, BaseModel):' | |||
|
4284 | 4290 | files_matches = True |
|
4285 | 4291 | if self.file_pattern != '*': |
|
4286 | 4292 | files_matches = False |
|
4287 | file_regex = re.compile(glob2re(self.file_pattern)) | |
|
4293 | if self.file_pattern.startswith('re:'): | |
|
4294 | file_pattern = self.file_pattern[3:] | |
|
4295 | else: | |
|
4296 | file_pattern = glob2re(self.file_pattern) | |
|
4297 | file_regex = re.compile(file_pattern) | |
|
4288 | 4298 | for filename in files_changed: |
|
4289 | 4299 | if file_regex.search(filename): |
|
4290 | 4300 | files_matches = True |
General Comments 0
You need to be logged in to leave comments.
Login now