Merge "Fix github branch protection while already unprotected"

This commit is contained in:
Zuul 2020-07-31 22:17:50 +00:00 committed by Gerrit Code Review
commit 47f63fbba1
2 changed files with 6 additions and 2 deletions

View File

@ -220,8 +220,9 @@ class FakeRepository(object):
def _set_branch_protection(self, branch_name, protected=True,
contexts=None):
if not protected and branch_name in self._branch_protection_rules:
del self._branch_protection_rules[branch_name]
if not protected:
if branch_name in self._branch_protection_rules:
del self._branch_protection_rules[branch_name]
return
rule = self._branch_protection_rules[branch_name]

View File

@ -1011,6 +1011,7 @@ class TestGithubDriver(ZuulTestCase):
github = self.fake_github.getGithubClient()
repo = github.repo_from_project(project)
repo._create_branch(branch)
repo._set_branch_protection(branch, False)
self.fake_github.emitEvent(
self.fake_github.getPushEvent(
@ -1113,6 +1114,7 @@ class TestGithubDriver(ZuulTestCase):
github = self.fake_github.getGithubClient()
repo = github.repo_from_project(project)
repo._create_branch(branch)
repo._set_branch_protection(branch, False)
A = self.fake_github.openFakePullRequest(project, branch, 'A')
old_sha = A.head_sha
@ -1569,6 +1571,7 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
github = self.fake_github.getGithubClient()
repo = github.repo_from_project(project)
repo._create_branch(branch)
repo._set_branch_protection(branch, False)
self.fake_github.emitEvent(
self.fake_github.getPushEvent(