Repository navigation
fix(artifacts-init): honor gh/glab git_protocol when picking push URL - #1469
0xDevNinja wants to merge 2 commits into
Conversation
|
heads up, the red checks here aren't the diff. it's a fork PR so the runner has no secrets and the eval tests just die on an empty API key before anything actually runs. the rest is green. if it's easier i can push this to a branch on the base repo and re-point the PR so it picks up secrets. lmk, no rush. |
|
@16francej — recommend closing this PR because #2225 supersedes it with broader handling for providers and explicit remote schemes. This version still fails when the remote is explicitly configured for HTTPS. Please retain the provider-detection tests and attribution under #2225. |
`gstack-artifacts-init` always converted the canonical HTTPS URL to its
SSH form for `git push origin`. Users on `gh config set git_protocol
https` (the `gh auth login` default) lack an SSH key on the remote, so
the post-create `git ls-remote $PUSH_URL` verification fails with a
cryptic SSH prompt and the script exits without finishing setup. Same
hazard on the gitlab branch.
Pre-fix the only recovery was rerunning with `--remote <https url>`,
which bypassed the canonicalization step entirely and required the user
to know the workaround.
Resolution order for the push URL:
1. `--push-protocol https|ssh` flag wins.
2. `auto` (default) reads `gh config get git_protocol` (github branch)
or `glab config get git_protocol` (gitlab branch).
3. Empty / unreadable config falls back to SSH — the historical
default, kept so users who never set `git_protocol` see no change.
Error message after a failed `ls-remote` also points HTTPS users at the
override flag, so the next attempt is one rerun away.
Fixes garrytan#1348
…-push-protocol auto The original git_protocol detection keyed only on --host, so it only ran for remotes gstack creates via gh/glab. A URL the user hands us through --remote, an existing origin, or a manual paste fell through to the SSH default — silently rewriting an explicitly-configured HTTPS remote to SSH. That's the July report on garrytan#1348: a user whose recovery URL was HTTPS got it converted back to SSH and the push failed. Track where REMOTE_URL came from. Under auto: - explicit / existing / manual: keep the scheme the URL already states (git@|ssh:// -> ssh, http(s):// -> https, anything else preserved verbatim). Never consult git_protocol for a URL the user supplied. - provider (gh/glab-created): honor git_protocol as before, SSH fallback. Explicit --push-protocol https|ssh still overrides everything. The reachability error now has a third branch for pass-through URLs. Refs garrytan#1348.
f12a6ee to
c454e2a
Compare
|
closed the gap you flagged rather than closing the PR. the explicit-HTTPS-remote case was real: the original detection only ran for gh/glab-created remotes, so a URL passed via added 4 regression tests, incl. one that pins an explicit HTTPS happy to defer to #2225 if the maintainers prefer that direction, but this branch now covers the same case, keeps the provider-detection tests, and is rebased onto current main. |
|
Thank you for this fix! The bug it addresses (#1348) has since been fixed on main and the issue is closed, so I'm closing this PR as done. Re-verified against current main (v1.91.12.0). If you think part of your change is still missing, reply and we'll reopen. Really appreciate the contribution. |
Summary
gstack-artifacts-initnow honorsgh config get git_protocol(andglab config get git_protocolfor the gitlab branch) when deriving the push URL.--push-protocol auto|https|sshflag lets users pin explicitly.autois the default.git_protocolsee no change.autopaths (github/gitlab × https/ssh), both explicit overrides, the unset-fallback, and invalid-value rejection.Fixes #1348.
Why
bin/gstack-artifacts-init:184(post v1.27.0.0 rename fromgstack-brain-init) unconditionally converts the canonical HTTPS URL to its SSH form forgit push origin:PUSH_URL=$("$URL_BIN" --to ssh "$CANONICAL_HTTPS" 2>/dev/null || echo "$CANONICAL_HTTPS")Users whose
gh auth logindefaulted to HTTPS (the gh default since 2.x) don't have an SSH key on the remote. The post-creategit ls-remote $PUSH_URLstep then hangs on an SSH prompt, exits, and the script bails withRemote not reachable via SSH:. Recovery required rerunning with--remote <https url>, which only works if the user knows the workaround.Same hazard on the gitlab branch —
glab config get git_protocolis parallel.Fix
Three-step resolution for the push URL:
--push-protocol https|sshflag wins (lets the user pin regardless of CLI state — useful in CI / scripted setups).auto(default) queries the per-host CLI config:github→gh config get git_protocolgitlab→glab config get git_protocolgit_protocol).The
ls-remotefailure message also now points HTTPS users at the override flag, so the next attempt is one rerun away rather than a workaround hunt.Tests
Extended the existing
makeFakeGh/makeFakeGlabshims with an optionalgitProtocolarg so they respond togh config get git_protocol(andglab config get git_protocol). Newdescribe('gstack-artifacts-init push protocol (issue #1348)')block, 7 cases:gh git_protocol=https→ origin URL is HTTPS.gh git_protocol=ssh→ origin URL is SSH (existing behavior preserved).gh git_protocolunset → origin URL is SSH (legacy default preserved).--push-protocol httpsoverridesgh git_protocol=ssh.--push-protocol sshoverridesgh git_protocol=https.--push-protocol bogusexits 1 withInvalid --push-protocol.glab git_protocol=https→ origin URL is HTTPS.Notes
--push-protocoldeliberately covers only the local push URL;~/.gstack-artifacts-remote.txtcontinues to store the canonical HTTPS form (codex Finding Add Claude Code marketplace configuration #10).gstack-artifacts-url --to ssh— that helper is still the right derivation primitive; only theautopolicy inartifacts-initchanges.Need help on this PR? Tag
@codesmithwith what you need.