Skip to content

[Bug]: Make Start Contribution idempotent when a branch or draft PR already exists #63

Description

@GhanshyamJha05

Describe the bug

Clicking Start Contribution more than once for the same issue is not idempotent. If the branch already exists, the API overwrites it and creates another draft pull request.

Steps to reproduce

Sign in to RepoSage with GitHub.
Open any GitHub issue.
Click Start Contribution.
Wait for the draft PR to be created.
Click Start Contribution again for the same issue.
Check the fork’s branch and pull requests.

Expected behavior

RepoSage should detect the existing branch or draft PR and return the existing contribution details, without modifying the branch or creating another PR.

Actual behavior

The existing branch error is ignored, a new empty commit is created, and the branch is force-updated. Another draft PR is then created for the same issue.

Environment

RepoSage: current main branch - Browser: Any modern browser OS: Windows, macOS, or Linux GitHub integration: GitHub OAuth ,Affected file: app/api/issues/start-contribution/route.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions