4.6 KiB
4.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,
refs/pull/<n>/headplushead.labelnormalization, and API error payloads.
- Added fixture-based regression harness for standard Gitea fields, fallback branch fields,
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
- Red regression check: copied the new
test-pr-metadata-gitea.shharness next toorigin/mainwrapper scripts and ran it withMOSAIC_TEST_WORK_DIR=$PWD/.mosaic-test-work/pr-metadata-gitea-red; it failed as expected withheadRefName=''andbaseRefName=''on the fixture API-error path. 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.MOSAIC_TEST_WORK_DIR=$PWD/.mosaic-test-work/pr-metadata-gitea packages/mosaic/framework/tools/git/test-pr-metadata-gitea.sh: passed; verifies standard Gitea fields, fallback branch fields,refs/pull/<n>/headlabel normalization, and nonzero API-error handling.- Installed wrapper parity:
/home/hermes/.config/mosaic/tools/git/{detect-platform.sh,pr-metadata.sh,pr-merge.sh}byte-match the PR source copies after validation, so active U-Connect wrapper invocations use the same fix while source PR review runs. - Live sanitized U-Connect metadata from
/src/uconnectwithMOSAIC_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=closed,host=git.uscllc.com.
- PR #1905:
- Merge preflight dry runs from installed wrappers:
- 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:
- PR:
https://git.mosaicstack.dev/mosaicstack/stack/pulls/518, branchfix/t-a292e96f-gitea-pr-metadata. - CI: Recent PR/push pipelines failed before clone/test execution due Woodpecker/Kubernetes PVC API timeout:
dial tcp 10.43.0.1:443: i/o timeout. No repository test step executed in CI; local targeted verification above remains clean.