fix(artifacts-init): honor gh/glab git_protocol when picking push URL#1469
Open
0xDevNinja wants to merge 1 commit into
Open
fix(artifacts-init): honor gh/glab git_protocol when picking push URL#14690xDevNinja wants to merge 1 commit into
0xDevNinja wants to merge 1 commit into
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.