3.6 KiB
3.6 KiB
t_a292e96f — Gitea PR metadata wrapper fix
Objective
Repair Mosaic git wrappers so Gitea PR metadata and merge preflight work for U-Connect PRs on git.uscllc.com without selecting the unrelated git.mosaicstack.dev tea login.
Findings
- Reproduced the failure from
/src/uconnect-worktrees/t_39ce717c-authentik-smoke-gatewith the currentpr-metadata.sh:- PR #1905 returned JSON with
number=null,baseRefName="",headRefName="". - PR #1908 returned JSON with
number=null,baseRefName="",headRefName="".
- PR #1905 returned JSON with
- Root cause: the wrapper treated HTTP/API error payloads as PR payloads and normalized missing fields to empty strings.
- The credential loader can return a non-working
git.uscllc.comAPI token in this environment, while host-specific~/.git-credentialsbasic auth succeeds. The wrapper now falls back by host before normalization. tea login listhas onlygit.mosaicstack.devconfigured here;pr-merge.shpreviously forced--login mosaicstack, which is invalid forgit.uscllc.comand causedLogin name mosaicstack does not exist.
Changes
packages/mosaic/framework/tools/git/detect-platform.sh- Added
get_gitea_basic_auth <host>to retrieve host-specific HTTPS credentials from~/.git-credentialswithout printing secrets.
- Added
packages/mosaic/framework/tools/git/pr-metadata.sh- Uses strict bash mode.
- Checks Gitea HTTP status and fails nonzero on API errors/non-JSON instead of emitting empty branch fields.
- Falls back from token auth to host-specific basic auth.
- Normalizes standard
head.ref/base.refand fallback branch fields. - Requires non-empty
headRefNameandbaseRefName. - Preserves GitHub
gh pr viewbehavior.
packages/mosaic/framework/tools/git/pr-merge.sh- Reads metadata once for base-branch policy preflight.
- Selects a
tealogin only when its configured URL matches the repo host. - Falls back to authenticated Gitea merge API when no matching
tealogin exists, avoiding the wrongmosaicstacklogin for USC repos. - Keeps squash-only and main-only merge policy.
packages/mosaic/framework/tools/git/test-pr-metadata-gitea.sh- Added fixture-based regression harness for standard Gitea fields, fallback branch fields, and API error payloads.
Documentation / changelog note
This repository currently has no root CHANGELOG.md; the scratchpad and docs/TASKS.md carry the task-level change record for this wrapper fix.
Verification log
bash -n packages/mosaic/framework/tools/git/{detect-platform.sh,pr-metadata.sh,pr-merge.sh,test-pr-metadata-gitea.sh}: passed.shellcheck -x -P . -e SC1090 packages/mosaic/framework/tools/git/{detect-platform.sh,pr-metadata.sh,pr-merge.sh,test-pr-metadata-gitea.sh}: passed.packages/mosaic/framework/tools/git/test-pr-metadata-gitea.sh: passed; verifies standard Gitea fields, fallback branch fields, and nonzero API-error handling.- Live sanitized U-Connect metadata from
/src/uconnect-worktrees/t_39ce717c-authentik-smoke-gatewithMOSAIC_CREDENTIALS_FILE=/src/jarvis-brain/credentials.json:- PR #1905:
number=1905,baseRefName=main,headRefName=edith/t_39ce717c-authentik-smoke-gate,state=open,host=git.uscllc.com. - PR #1908:
number=1908,baseRefName=main,headRefName=fix/t_23fa9e1d-portal-health-backend,state=open,host=git.uscllc.com.
- PR #1905:
- Merge preflight dry runs:
- PR #1905:
Dry run: would merge PR #1905 on git.uscllc.com with authenticated Gitea API fallback (base=main, method=squash). - PR #1908:
Dry run: would merge PR #1908 on git.uscllc.com with authenticated Gitea API fallback (base=main, method=squash).
- PR #1905: