[FIX]: fix codeowner

A corner case was discovered when a pr is open but the pr is not in the
codeowner commits.
This commit is contained in:
Xavier-Do 2022-12-23 18:38:10 +01:00 committed by xdo
parent ad573d64cf
commit 910843f06d
2 changed files with 7 additions and 4 deletions

View File

@ -1116,9 +1116,11 @@ class ConfigStep(models.Model):
success = False
return success
def _modified_files(self, build, commit_link_links = None):
def _modified_files(self, build, commit_link_links=None):
modified_files = {}
for commit_link in commit_link_links or build.params_id.commit_link_ids:
if commit_link_links is None:
commit_link_links = build.params_id.commit_link_ids
for commit_link in commit_link_links:
commit = commit_link.commit_id
modified = commit.repo_id._git(['diff', '--name-only', '%s..%s' % (commit_link.merge_base_commit_id.name, commit.name)])
if modified:

View File

@ -29,7 +29,7 @@ class ConfigStep(models.Model):
for codeowner in codeowners:
github_teams = codeowner._get_github_teams()
if github_teams and codeowner.regex and (codeowner._match_version(version_id)):
team_set = regexes.setdefault(codeowner.regex.strip(), set())
team_set = regexes.setdefault(codeowner.regex.strip(), set())
team_set |= set(t.strip() for t in github_teams)
return list(regexes.items())
@ -73,7 +73,8 @@ class ConfigStep(models.Model):
if not self._check_limits(build):
return
prs = bundle.branch_ids.filtered(lambda branch: branch.is_pr and branch.alive)
build_repositories = build.params_id.commit_link_ids.commit_id.repo_id
prs = bundle.branch_ids.filtered(lambda branch: branch.is_pr and branch.alive and (branch.remote_id.repo_id in build_repositories))
# skip draft pr
draft_prs = prs.filtered(lambda pr: pr.draft)