You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use shared git helpers for code-mappings repo inference (#1087)
## Summary
Follow-up fix for #1086 — replaces buggy custom git helpers in
`code-mappings upload` with the well-tested shared helpers from
`src/lib/git.ts`.
## What was broken
The `SSH_REMOTE_RE` regex (`:(.+?)(?:\.git)?$`) in `upload.ts`
incorrectly matched HTTPS URLs because they contain `:` (in `https:`).
This produced garbage repo names:
| Remote URL | Expected | Got |
|-----------|----------|-----|
| `https://github.com/owner/repo.git` | `owner/repo` |
`//github.com/owner/repo` |
| `ssh://git@github.com:22/owner/repo.git` | `owner/repo` |
`//git@github.com:22/owner/repo` |
The corrupted name was sent to the Sentry API as the `repository` field.
## What this fixes
1. **Buggy regex replaced** — Uses `parseRemoteUrl()` from
`src/lib/git.ts` which correctly tries `new URL()` first (handles
https/ssh/git protocols) and only falls back to SCP-style regex when URL
parsing fails.
2. **Shell injection risk removed** — Replaced `execSync` (shell) with
`execFileSync` (no shell) via the shared `git()` helper.
3. **Code consolidated** — New `inferRepositoryName()` and
`inferDefaultBranch()` functions in `git.ts` replace the duplicated
logic in `upload.ts`. Both use `this.cwd` for correct working directory.
4. **ASCII art dividers removed** — Per AGENTS.md prohibited comment
styles, replaced `// ── Section ───` dividers with plain `// Section` in
code-mappings and dart-symbol-map files.
## Files changed
| File | Change |
|------|--------|
| `src/lib/git.ts` | Added `inferRepositoryName()` and
`inferDefaultBranch()` |
| `src/commands/code-mappings/upload.ts` | Removed custom git helpers,
imported from git.ts |
| `src/lib/api/code-mappings.ts` | Removed ASCII art dividers |
| `src/commands/dart-symbol-map/upload.ts` | Removed ASCII art dividers
|
| `src/lib/api/dart-symbols.ts` | Removed ASCII art dividers |
Net: **66 insertions, 96 deletions** (less code, more correct)
***Always batch multiple fixes into a single implementation pass with tests verified after**: When addressing code review findings, the user groups all fixes into a single batch (e.g., 'Fix 1 through Fix 6') and applies them together in one commit/pass, then runs the full test suite once at the end to confirm all tests pass. The user does not apply fixes incrementally with separate test runs between each fix. Fixes are prioritized by severity (Critical → Medium → Low → Nit) but all delivered together. The user expects the assistant to implement all requested fixes in one coordinated effort and report a single consolidated test result.
***Always fix lint errors immediately after they are flagged, even if it overrides prior directives**: When Biome (or any linter) flags an error in modified files, the user expects it to be fixed right away — even if a prior directive said otherwise (e.g., 'keep handleScriptOutput async' was overridden when the linter flagged useAwait). The user does not defer lint fixes or leave them as known issues. After applying a fix, always re-run the linter to confirm a clean result before considering the task done. Pre-existing lint errors in unmodified files are noted but not fixed unless they are in files the current work touches.
* **Always migrate Bun-specific APIs and tooling to Node.js equivalents**: Bun→Node.js migration complete. Replace Bun APIs: \`Bun.spawn\`→\`node:child\_process\`, \`Bun.sleep\`→\`node:timers/promises\`, \`bun:sqlite\`→\`node:sqlite\`, \`bun run\`→\`pnpm run\`/\`tsx\`, \`Bun.file().text()\`→\`readFile(path,'utf-8')\`, \`Bun.write()\`→\`writeFile()\`, \`Bun.which()\`→Node-compatible pkg, \`Bun.Glob\`→\`tinyglobby\`/\`picomatch\`, \`Bun.randomUUIDv7()\`→\`uuidv7\`, \`Bun.semver.order()\`→\`semver.compare()\`, \`Bun.zstdCompressSync()\`→zlib/\`zstd-napi\`. Exception: \`script/build.ts\` uses fossilize (not \`Bun.build\`) and stays on Bun for build-binary CI job. \`script/bundle.ts\` uses esbuild via tsx. \`packageManager\`: \`pnpm@10.11.0\`. bun.lock deleted, vitest.config.ts added. \`.npmrc\`: \`node-linker=hoisted\`. \`patchedDependencies\` moved to \`pnpm\` config block. \`NODE\_VERSION='lts'\`. \`new Worker(new URL(...))\` HANGS in SEA — use Blob+URL.createObjectURL. \`textImportPlugin\` handles \`with { type: 'text' }\` (inline as string) and \`with { type: 'file' }\` (pre-bundle sidecar) for esbuild. Prefer \`import { setTimeout } from 'node:timers/promises'\` over \`new Promise((r) => setTimeout(r, ms))\` — the latter is used in chunk-upload.ts/proguard.ts but is inconsistent with broader project direction.
***Always verify fixes by running tests and confirming all pass**: After applying any code fix or change, the user consistently runs the relevant test suite and expects confirmation that all tests pass (with exact counts and duration). The user also expects new tests to be added for each non-trivial fix to verify the specific behavior changed. Test results should be reported with file names, test counts, and timing. If tests fail, the session is not considered complete. This pattern applies to bug fixes, refactors, and feature additions alike.
0 commit comments