garrytan / garrytan/gstack

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

Open
#2,765 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
133k
Forks
19.9k
Avg merge
18h 46m
Merged PRs (30d)
26

Description

## Summary

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

```
gh pr view --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.

Contributor guide

Open the contributing guide

Research direction

Start at the /land-and-deploy entry point and review the ownership logic absorbed from #2725, including its test pins. Check how the command currently compares the PR head repository with the checkout remote, then inspect the gh repo view API fields. Done means canonical repository identity is used for both fork and base branches and the affected #2725 tests cover the repro shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.