Skip to content

fix(cnb): persist git credential helper after interactive clone - #528

Merged
jeff-r2026 merged 1 commit into
mainfrom
hotfix/cnb-clone-credential
Sep 12, 2026
Merged

fix(cnb): persist git credential helper after interactive clone#528
jeff-r2026 merged 1 commit into
mainfrom
hotfix/cnb-clone-credential

Conversation

@jeff-r2026

@jeff-r2026 jeff-r2026 commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Problem

teamai init https://cnb.cool/<owner>/<repo> prompted for Username/Password during the post-clone push (member registration), and teamai pull failed with couldn't find remote ref main — despite the user being logged into the cnb CLI.

Root cause

cnbRepoClone used git -c credential.helper='!cnb git-credential' clone. The -c flag only applies to that single invocation — it never reaches the cloned repo's .git/config. So remote.origin.url stays 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:

git config --local credential.helper '!cnb git-credential'

Token-path clones (CI) already bake creds into the URL, so they skip this step.

Test plan

  • Unit tests: 3 new cases covering helper persistence (interactive path), token-path skip, and not-found error. tsc --noEmit clean.
  • End-to-end against a real cnb.cool account (logged-in, no 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 (was fatal: couldn't find remote ref main)
    • git config --local --get credential.helper on the clone → !cnb git-credential
    • remote.origin.url stays clean (no embedded token on the interactive path)

Scope

Surgical: only cnbRepoClone changed (+23 lines); no other providers touched.

References

`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".
@jeff-r2026
jeff-r2026 merged commit 041e6db into main Sep 12, 2026
7 checks passed
@jeff-r2026
jeff-r2026 deleted the hotfix/cnb-clone-credential branch September 12, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant