fix(gbrain): strip .git when the remote URL has a trailing slash#1896
Open
jbetala7 wants to merge 1 commit into
Open
fix(gbrain): strip .git when the remote URL has a trailing slash#1896jbetala7 wants to merge 1 commit into
jbetala7 wants to merge 1 commit into
Conversation
canonicalizeRemote() stripped the trailing `.git` suffix before stripping trailing slashes. Because the `.git$` match is anchored on end-of-string, a remote written with a trailing slash (e.g. `.../repo.git/`) skipped the `.git` strip and canonicalized to `.../repo.git` instead of `.../repo`. That key is the cross-machine dedup key and feeds gbrain code source-ids (deriveCodeSourceId / deriveLegacyCodeSourceId, gstack-memory-ingest), so the same repo produced different source-ids depending on whether origin had a trailing slash, splitting federated cross-source search. Reorder so trailing slash(es) are stripped first, then `.git`. Adds regression tests for the `.git/` combination (proven to fail pre-fix). Fixes garrytan#1895 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
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
canonicalizeRemote()(lib/gstack-memory-helpers.ts) is the canonicalhost/org/repodedup key — no scheme, no trailing.git. When a configuredoriginURL ends with a trailing slash (e.g.git remote add origin https://github.com/garrytan/gstack.git/, which is valid and clones fine) the.gitsuffix was not stripped:Root cause
.gitwas stripped before trailing slashes, and the.git$regex is anchored on end-of-string:This key feeds gbrain code source-ids (
deriveCodeSourceId/deriveLegacyCodeSourceIdinbin/gstack-gbrain-sync.ts, andbin/gstack-memory-ingest.ts), which join the last two path segments. So the same repo produced different source-ids across machines depending on whetherorigincarried a trailing slash (gstack-code-garrytan-gstack-<hash>vsgstack-code-garrytan-gstack-git-<hash>after id sanitization) — splitting federated cross-source search, the exact thing the canonical key exists to prevent.Fix
Strip trailing slash(es) first, then the
.gitsuffix (a reorder of the two existing steps). No behavior change for any input that previously canonicalized correctly.Testing
bun test test/gstack-memory-helpers.test.ts— 27 pass (was 25; +2 new cases).Added regression tests for the
.git/combination, proven to fail onmainbefore the fix:Also ran the downstream consumer suite
bun test test/gstack-gbrain-sync.test.ts— 37 pass, 0 fail.Fixes #1895