Skip to content

Commit

Permalink
Merge pull request #10
Browse files Browse the repository at this point in the history
2.1.3
  • Loading branch information
igcherkaev authored Sep 7, 2022
2 parents 0305df9 + f9e0415 commit 487508a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
10 changes: 8 additions & 2 deletions actions/lib/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ def branch_protection_to_dict(branch_protection):
result[attr] = {}
for attr2 in required_pull_request_reviews_attributes:
if attr2 == 'dismissal_users':
users = [user.login for user in req_pr_reviews.dismissal_users]
if req_pr_reviews.dismissal_users is not None:
users = [user.login for user in req_pr_reviews.dismissal_users]
else:
users = None
result[attr][attr2] = users
elif attr2 == 'dismissal_teams':
teams = [team.slug for team in req_pr_reviews.dismissal_teams]
if req_pr_reviews.dismissal_teams is not None:
teams = [team.slug for team in req_pr_reviews.dismissal_teams]
else:
teams = None
result[attr][attr2] = teams
else:
result[attr][attr2] = getattr(req_pr_reviews, attr2)
Expand Down
15 changes: 12 additions & 3 deletions actions/update_branch_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def run(self, user, repo, branch, required_status_checks, enforce_admins,
user_push_restrictions = restrictions['user_push_restrictions']
team_push_restrictions = restrictions['team_push_restrictions']

if not dismissal_users:
dismissal_users = NotSet
if not dismissal_teams:
dismissal_teams = NotSet

branch.edit_protection(strict=strict, contexts=contexts,
enforce_admins=enforce_admins,
dismissal_users=dismissal_users,
Expand All @@ -64,9 +69,13 @@ def run(self, user, repo, branch, required_status_checks, enforce_admins,
GITHUB_BRANCH = os.environ.get('GITHUB_BRANCH')

# As produced by get_branch_protection action
BRANCH_PROTECTION = {'enforce_admins': True,
'required_pull_request_reviews': None,
'required_status_checks': {'contexts': [], 'strict': True},
BRANCH_PROTECTION = {'enforce_admins': False,
'required_pull_request_reviews': {'dismiss_stale_reviews': False,
'dismissal_teams': None,
'dismissal_users': None,
'require_code_owner_reviews': False,
'required_approving_review_count': 0},
'required_status_checks': None,
'restrictions': None
}

Expand Down
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords:
- git
- scm
- serverless
version: 2.1.2
version: 2.1.3
python_versions:
- "3"
author : StackStorm, Inc.
Expand Down

0 comments on commit 487508a

Please sign in to comment.