From f16ff3f4fdb13a9a5fc61d97efc6282f91af5b89 Mon Sep 17 00:00:00 2001 From: Ashley Childress Date: Fri, 28 Aug 2026 22:33:38 -0400 Subject: [PATCH] fix: open community PRs against the repository default branch - query the repo for its default branch instead of assuming main - use that branch as both the fork point and the pull request base Generated-by: Claude Opus 5 --- src/contributions/approve_submission.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/contributions/approve_submission.py b/src/contributions/approve_submission.py index c7d959e..d5ae507 100644 --- a/src/contributions/approve_submission.py +++ b/src/contributions/approve_submission.py @@ -72,9 +72,14 @@ def add_issue_comment(issue_number: int, body: str) -> None: github_api_request("POST", f"/issues/{issue_number}/comments", {"body": body}) -def get_default_branch_sha() -> str: - """Get the SHA of the default branch (main).""" - ref = github_api_request("GET", "/git/ref/heads/main") +def get_default_branch() -> str: + """Get the repository's default branch name.""" + return github_api_request("GET", "")["default_branch"] + + +def get_branch_sha(branch: str) -> str: + """Get the head SHA of a branch.""" + ref = github_api_request("GET", f"/git/ref/heads/{branch}") return ref["object"]["sha"] @@ -199,8 +204,8 @@ def process_submission( # Create branch branch_name = f"community-submission-{issue_number}" - default_sha = get_default_branch_sha() - create_branch(branch_name, default_sha) + base_branch = get_default_branch() + create_branch(branch_name, get_branch_sha(base_branch)) # Create file commit_message = f"Add community submission from @{author_username} (closes #{issue_number})" @@ -276,7 +281,7 @@ Closes #{issue_number} pr = create_pull_request( title=f"Community submission: {filename}", head=branch_name, - base="main", + base=base_branch, body=pr_body, )