fix(cnb): persist git credential helper after interactive clone - #528
Merged
Conversation
`teamai init` cloned CNB repos via `git -c credential.helper='!cnb git-credential' clone`, but the `-c` flag only applies to that single invocation — it never reached the cloned repo's `.git/config`. So `remote.origin.url` stayed credential-free, and the subsequent push (member registration) plus `teamai pull` fell back to an interactive Username/Password prompt despite the user being logged into the `cnb` CLI. GitHub/TGit solve this by embedding the token in the clone URL (persisted into remote.origin.url); CNB's CI path (CNB_TOKEN) does the same. Only the interactive-login path was missing persistence. Persist the helper into the repo's local config after a successful interactive clone so every later git operation authenticates transparently. Verified end-to-end against a real cnb.cool account (logged-in, no CNB_TOKEN): `teamai init https://cnb.cool/test1122444/test` now pushes member registration without prompting, and `teamai pull` reports up to date instead of "couldn't find remote ref".
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.
Problem
teamai init https://cnb.cool/<owner>/<repo>prompted for Username/Password during the post-clone push (member registration), andteamai pullfailed withcouldn't find remote ref main— despite the user being logged into thecnbCLI.Root cause
cnbRepoCloneusedgit -c credential.helper='!cnb git-credential' clone. The-cflag only applies to that single invocation — it never reaches the cloned repo's.git/config. Soremote.origin.urlstays credential-free, and every later git operation (push, pull) falls back to an interactive Username/Password prompt.GitHub/TGit solve this by embedding the token in the clone URL (persisted into
remote.origin.url); CNB's CI path (CNB_TOKEN) does the same. Only the interactive-login path was missing persistence.Fix
After a successful interactive clone (no
CNB_TOKEN), persist the credential helper into the cloned repo's local config:Token-path clones (CI) already bake creds into the URL, so they skip this step.
Test plan
tsc --noEmitclean.CNB_TOKEN):teamai init https://cnb.cool/test1122444/test --force→✔ Member registration pushed to team repo(no prompt)teamai pull→✔ Team repo: already up to date(wasfatal: couldn't find remote ref main)git config --local --get credential.helperon the clone →!cnb git-credentialremote.origin.urlstays clean (no embedded token on the interactive path)Scope
Surgical: only
cnbRepoClonechanged (+23 lines); no other providers touched.References
cnb login→teamai init https://cnb.cool/...) is exactly the interactive-login path this PR makes work without a Username/Password prompt.