Skip to content

Commit

Permalink
feat: enable repo branch protection by default for conda-forge
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Sep 6, 2024
1 parent 8534046 commit c049489
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions conda_smithy/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ def get_cached_team(org, team_name, description=""):
return team


def _conda_forge_specific_repo_setup(gh_repo):
branch = gh_repo.get_branch(gh_repo.default_branch)
branch.edit_protection(
enforce_admins=True,
allow_force_pushes=False,
allow_deletions=False,
)


def create_github_repo(args):
token = gh_token()

Expand All @@ -115,13 +124,16 @@ def create_github_repo(args):

gh = Github(token)
user_or_org = None
is_conda_forge = False
if args.user is not None:
pass
# User has been defined, and organization has not.
user_or_org = gh.get_user()
else:
# Use the organization provided.
user_or_org = gh.get_organization(args.organization)
if args.organization == "conda-forge":
is_conda_forge = True

repo_name = f"{feedstock_name}-feedstock"
try:
Expand All @@ -131,6 +143,10 @@ def create_github_repo(args):
private=args.private,
description=f"A conda-smithy repository for {feedstock_name}.",
)

if is_conda_forge:
_conda_forge_specific_repo_setup(gh_repo)

print(f"Created {gh_repo.full_name} on github")
except GithubException as gh_except:
if (
Expand Down
23 changes: 23 additions & 0 deletions news/branch-protection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Enabled branch protection for ``conda-forge`` feedstocks by default. (#)

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>

0 comments on commit c049489

Please sign in to comment.