Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 24, 2025

This PR improves the handling of draft PRs in repositories that don't support them. The current implementation has a simple heuristic that disables draft PRs for all private repositories, but this isn't reliable as some private repositories do support draft PRs while some public ones might not.

Changes

  1. Added a new _supports_draft_prs instance variable to cache whether a repository supports draft PRs

  2. Implemented a new accepts_draft_prs() method that:

    • Uses the cached result if available
    • Assumes public repositories always support draft PRs
    • Conservatively assumes private repositories don't support draft PRs by default
  3. Modified the create_pull method to:

    • First check if draft PRs are supported using the new method
    • Try creating a draft PR only if supported
    • If a draft PR creation fails with the specific error "Draft pull requests are not supported in this repository", fall back to creating a regular PR
    • Update the cached knowledge about draft PR support

This approach:

  • Minimizes API calls to GitHub
  • Gracefully handles the error case when draft PRs aren't supported
  • Provides a fallback mechanism to create regular PRs
  • Caches the result to avoid repeated failures

Fixes CG-11610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants