Skip to content

land-and-deploy: fork-branch ownership check can misread anonymous-HTTPS remotes #2765

Description

@garrytan

Summary

/land-and-deploy's fork-branch check (absorbed from #2725 in v1.78.0.0) resolves PR head ownership with:

gh pr view <N> --json headRepositoryOwner,headRepository,headRefName \
  --jq '"\(.headRepositoryOwner.login)/\(.headRepository.name)\t\(.headRefName)"'

That fixed the empty-owner bug on gh 2.83 and is verified live for the common setups. The residual edge: when the local remote is an anonymous HTTPS URL (no owner segment inferable, or an ssh-vs-https shape mismatch against the composed owner/name), the string comparison between the composed head repo and the local remote can misread ownership — the skill could give fork guidance to a non-fork branch, or treat a fork branch as local.

Repro shape

  1. Clone via a mirror/proxy or credential-helper setup where git remote get-url origin returns an anonymous HTTPS URL that does not textually contain owner/name in the expected position (e.g. a self-hosted mirror path, or https://github.com/OWNER/REPO vs the SSH remote form (ssh:// / scp-style) casing/format drift).
  2. Run /land-and-deploy on a PR whose head repo IS the base repo.
  3. The ownership comparison misses and the skill walks the fork path (or vice versa).

Proposed fix

Resolve ownership canonically from the API instead of URL parsing: compare headRepository.nameWithOwner-composed identity against gh repo view --json nameWithOwner (the checkout's canonical repo), never against remote URL text. Touches the #2725 test pins, so it should be coordinated with that absorption's tests rather than hot-patched.

Why deferred

Decided at v1.78.0.0 ship time (wave PR #2752): the absorbed command is correct for every setup verified live; re-editing pinned community work at ship time for an unobserved edge adds churn. Filed instead with this repro shape.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions