Skip to content

Commit

Permalink
Merge pull request #175 from creativecommons/api-fixes
Browse files Browse the repository at this point in the history
Resolve GitHub API error and Asana API warning
  • Loading branch information
TimidRobot authored Jul 24, 2023
2 parents 45163e6 + 9c37348 commit 6671d63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 1 addition & 7 deletions ccos/data/get_community_team_data.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
This script pulls the members of the "Community Team Tracking" Asana
project, formats it a bit, then pushes it to a databag
"databags/community_team_list.json"
in creativecommons/creativecommons.github.io-source
"""

# Standard library
import inspect
import logging
Expand Down Expand Up @@ -33,6 +26,7 @@ def setup_asana_client():
LOG.critical("missin ADMIN_ASANA_TOKEN environment variable")
sys.exit(1)
asana_client = asana.Client.access_token(asana_token)
asana_client.headers = {"asana-enable": "new_goal_memberships"}
try:
# Perform simple API operation to test authentication
asana_client.workspaces.get_workspace(ASANA_WORKSPACE_GID)
Expand Down
13 changes: 12 additions & 1 deletion normalize_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,28 @@ def update_branch_protection(repo):
and is_engineering_project(repo)
):
LOG.info(f"{repo.name}: updating branch protections")
# The following empty *_bypass_pull_request_allowance arguments ensure
# the required bypass_pull_request_allowances API parameter is
# populated:
# https://docs.github.com/rest/branches/branch-protection#update-branch-protection
if repo.name in branch_protections.REQUIRED_STATUS_CHECK_MAP:
default_branch.edit_protection(
required_approving_review_count=1,
user_push_restrictions=[],
contexts=branch_protections.REQUIRED_STATUS_CHECK_MAP[
repo.name
],
users_bypass_pull_request_allowances=[],
teams_bypass_pull_request_allowances=[],
apps_bypass_pull_request_allowances=[],
)
else:
default_branch.edit_protection(
required_approving_review_count=1, user_push_restrictions=[]
required_approving_review_count=1,
user_push_restrictions=[],
users_bypass_pull_request_allowances=[],
teams_bypass_pull_request_allowances=[],
apps_bypass_pull_request_allowances=[],
)
else:
LOG.info(f"{repo.name}: skipping: exempt")
Expand Down

0 comments on commit 6671d63

Please sign in to comment.