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
{{ message }}
Repository navigation
canonicalizeRemote keeps the .git suffix when the remote URL has a trailing slash, splitting the dedup/source-id key #1895
canonicalizeRemote() in lib/gstack-memory-helpers.ts is documented to produce a canonical host/org/repo key with no scheme and no trailing .git. It is used as the cross-machine dedup key and to derive gbrain code source-ids (bin/gstack-gbrain-sync.tsderiveCodeSourceId/deriveLegacyCodeSourceId, bin/gstack-memory-ingest.ts).
When the configured origin URL ends with a trailing slash (e.g. git remote add origin https://github.com/garrytan/gstack.git/ — valid, clones fine), the .git suffix is not stripped:
The two normalization steps run in the wrong order:
// strip trailing .gits=s.replace(/\.git$/i,"");// anchored on $ — fails when a slash follows// strip trailing slashs=s.replace(/\/+$/,"");
With a trailing slash present, the \.git$ anchor does not match (the string ends in /, not .git), so .git survives; the trailing slash is then removed, leaving ...gstack.git.
Downstream, deriveCodeSourceId joins the last two path segments, so the same repo yields different source-ids on different machines depending on whether origin has a trailing slash (gstack-code-garrytan-gstack-<hash> vs gstack-code-garrytan-gstack-git-<hash> after id sanitization). Federated cross-source search then splits/duplicates hits for one repo — exactly what the canonical key exists to prevent.
Expected behavior
A remote written with a trailing slash must canonicalize to the same key as one without:
@16francej Please close this issue as resolved. Current main removes trailing slashes before normalizing the .git suffix, so equivalent remote URLs now produce the same identity key. This shipped in #2264.
Verified already fixed on main by 1aa5283d fix(gbrain): canonicalize remotes with trailing slashes — closing with receipts. canonicalizeRemote now strips trailing slashes both before and after the .git suffix strip, so .../repo.git/ and /repo/.git canonicalize to the same identity instead of splitting the dedup/source-id key. Pinned by test/gstack-memory-helpers.test.ts.
(Audited during fork-port wave 2 planning; see #2577.)
Activity
fix(gbrain): strip .git when the remote URL has a trailing slash
time-attack commentedon Jul 15, 2026
@16francej Please close this issue as resolved. Current main removes trailing slashes before normalizing the .git suffix, so equivalent remote URLs now produce the same identity key. This shipped in #2264.
garrytan commentedon Aug 15, 2026
Verified already fixed on main by
1aa5283dfix(gbrain): canonicalize remotes with trailing slashes — closing with receipts.canonicalizeRemotenow strips trailing slashes both before and after the.gitsuffix strip, so.../repo.git/and/repo/.gitcanonicalize to the same identity instead of splitting the dedup/source-id key. Pinned bytest/gstack-memory-helpers.test.ts.(Audited during fork-port wave 2 planning; see #2577.)