Skip to content

refactor: migrate cherry-pick PR creation from hub to gh CLI #1023

@myakove

Description

@myakove

Summary

Replace the deprecated hub CLI with GitHub's official gh CLI for cherry-pick PR creation in the webhook server.

Problem / Motivation

The cherry-pick flow in runner_handler.py uses the hub CLI (v2.14.2) to create pull requests. hub is an archived/deprecated project (last release 2020) maintained by mislav. GitHub's official CLI gh is the modern replacement and is actively maintained.

Current Usage

hub is used in exactly one place — webhook_server/libs/handlers/runner_handler.py (lines 717, 725-729):

hub_cmd = f"GITHUB_TOKEN={github_token} hub --work-tree={worktree_path} --git-dir={worktree_path}/.git"
# ...
f'bash -c "{hub_cmd} pull-request -b {target_branch} -h {new_branch_name} -l {CHERRY_PICKED_LABEL} {assignee_flag} -m \'...\' -m \'...\'"'

hub is installed in the Dockerfile (lines 75-76) via a manual download from GitHub releases.

Proposed Changes

1. Replace hub command with gh equivalent

hub flag gh equivalent Purpose
-b <branch> --base <branch> Base branch
-h <branch> --head <branch> Head branch
-l <label> --label <label> Add label
-a <user> --assignee <user> Assign user
-m <title> --title <title> PR title
-m <body> (2nd) --body <body> PR description

2. Update Dockerfile

  • Remove hub installation (lines 75-76)
  • Add gh CLI installation

3. Update authentication

  • hub uses GITHUB_TOKEN env var
  • gh uses GH_TOKEN or GITHUB_TOKEN env var (both work), or gh auth login

Requirements

  1. Replace hub pull-request command with gh pr create in runner_handler.py
  2. Update Dockerfile to remove hub and add gh CLI
  3. Update tests for the cherry-pick flow
  4. Verify authentication works with gh CLI

Deliverables

  • Replace hub pull-request with gh pr create in runner_handler.py
  • Update Dockerfile: remove hub, add gh CLI
  • Update tests for the cherry-pick flow
  • Verify authentication works with gh CLI

Notes

This is a prerequisite for #1022 (AI-powered conflict resolution for auto cherry-pick), which will significantly modify the cherry-pick method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions