Skip to content

feat(finish): Replace 'gh' dependency with direct GitHub API for PR creation #66

@duizendstra

Description

@duizendstra

Problem

The cv finish command currently relies on the user having the GitHub CLI (gh) installed and separately authenticated. As demonstrated in a recent user session, if gh is not authenticated (gh auth login), the command fails with a non-obvious error (exit status 4).

This creates a brittle external dependency and a poor user experience. The cv tool should manage its own authentication for core features.

Proposed Solution

Refactor the cv finish command to remove the call to the gh pr create executable. Instead, it should use the internal GitHub client (internal/github) to create the pull request directly via the GitHub API.

This approach has several advantages:

  • It removes the dependency on the gh CLI being installed.
  • It centralizes authentication; the command will rely on the GITHUB_TOKEN environment variable, which is the same token used by other cv project commands.
  • It makes the command more robust and suitable for automated environments.

Acceptance Criteria

  1. The cv finish command no longer executes the gh binary.
  2. When run, cv finish successfully creates a pull request against the repository's default branch using the GitHub API.
  3. The command gracefully handles cases where the GITHUB_TOKEN is missing or invalid with a clear, user-friendly error message.
  4. The command should still intelligently pre-fill the pull request title and body from the branch's commits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions