Skip to content

Commit

Permalink
[PTFE-583] ✨ Prevent creation of integration branches
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspardmoindrot committed Jul 26, 2023
1 parent eabb154 commit 6d813d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
18 changes: 11 additions & 7 deletions bert_e/tests/test_bert_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,14 +1250,15 @@ def test_request_integration_branch_by_creating_pull_requests(self):
pr.id, settings=settings, options=options, backtrace=True)
self.assertEqual(len(list(pr.get_comments())), 4)
self.assertIn('Integration data created', self.get_last_pr_comment(pr))

options = self.bypass_all
with self.assertRaises(exns.SuccessMessage):
self.handle(
pr.id, settings=settings, options=options, backtrace=True)

self.assertIn(
'I have successfully merged the changeset', self.get_last_pr_comment(pr))
'I have successfully merged the changeset',
self.get_last_pr_comment(pr))

def test_creation_integration_branch_by_approve(self):
"""Test pr.approve() to request integration branches creation.
Expand Down Expand Up @@ -1291,19 +1292,21 @@ def test_creation_integration_branch_by_approve(self):
prs = [pr_1, pr_2]

for pr in prs:
options = self.bypass_all_but(['bypass_build_status', 'bypass_author_approval'])
options = self.bypass_all_but(['bypass_build_status',
'bypass_author_approval'])
with self.assertRaises(exns.ApprovalRequired):
self.handle(pr.id, options=options, backtrace=True)

self.assertEqual(len(list(pr.get_comments())), 3)

self.assertIn(
'Integration data created', list(pr.get_comments())[-2].text)
'Integration data created', list(pr.get_comments())[-2].text)

self.assertIn(
'Waiting for approval', self.get_last_pr_comment(pr))
self.assertIn(
'The following approvals are needed', self.get_last_pr_comment(pr))
'The following approvals are needed',
self.get_last_pr_comment(pr))

if pr.src_branch == "feature/TEST-0069":
pr.approve()
Expand All @@ -1318,9 +1321,10 @@ def test_creation_integration_branch_by_approve(self):
with self.assertRaises(exns.SuccessMessage):
self.handle(
pr.id, settings=settings, options=options, backtrace=True)

self.assertIn(
'I have successfully merged the changeset', self.get_last_pr_comment(pr))
'I have successfully merged the changeset',
self.get_last_pr_comment(pr))

def test_integration_branch_creation_latest_branch(self):
"""Test there is no comment to request integration branches creation.
Expand Down
12 changes: 6 additions & 6 deletions bert_e/workflow/gitwaterflow/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ def check_integration_branches(job):
approved_by_author = job.pull_request.author in approvals

create_integration = (job.settings.always_create_integration_branches or
job.settings.create_integration_branches)
job.settings.create_integration_branches)
create_prs = (job.settings.always_create_integration_pull_requests or
job.settings.create_pull_requests)
job.settings.create_pull_requests)
multiple_dst_branches = len(job.git.cascade.dst_branches) <= 1

if not (create_integration
or create_prs
or approved_by_author
or multiple_dst_branches):
if not (create_integration or
create_prs or
approved_by_author or
multiple_dst_branches):
raise exceptions.RequestIntegrationBranches(
active_options=job.active_options,
)
Expand Down

0 comments on commit 6d813d1

Please sign in to comment.