Skip to content

Commit e3a57a2

Browse files
committed
[FIX] vcp_github: do not create a branch when fetching pull request, if the target branch doesn't fetch the pattern
1 parent 51a93d8 commit e3a57a2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

vcp_github/models/vcp_repository.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def _update_branches_github(self):
5656
raise ValidationError(self.env._(f"Reset on {reset}")) from e
5757

5858
def _parse_github_pr(self, pr, client):
59+
self.ensure_one()
5960
origin_data = pr.as_dict()
6061
comments_url = pr.comments_url
6162
comments_req = client.session.get(comments_url)
@@ -71,12 +72,22 @@ def _parse_github_pr(self, pr, client):
7172
reviews_url = reviews_req.links["next"]["url"]
7273
reviews_req = client.session.get(reviews_url)
7374
reviews += reviews_req.json()
75+
76+
branch_pattern = (
77+
self.fetch_branch_pattern
78+
or self.platform_id.fetch_repository_branch_pattern
79+
or False
80+
)
81+
if branch_pattern and not re.match(branch_pattern, pr.base.ref):
82+
branch_id = False
83+
else:
84+
branch_id = self.platform_id._get_branch(pr.base.ref)
7485
return (
7586
str(pr.id),
7687
{
7788
"user_id": self.platform_id.host_id._get_user(pr.user.login),
7889
"repository_id": self.id,
79-
"branch_id": self.platform_id._get_branch(pr.base.ref),
90+
"branch_id": branch_id,
8091
"organization_id": self.platform_id.host_id._get_organization(
8192
pr.head.repo[0]
8293
),

0 commit comments

Comments
 (0)