Use git remote URL for repo container tags#28
Conversation
Use git remote URL instead of folder name for consistent repo container tags - Use `git remote get-url origin` to derive repo name for container tags instead of relying solely on folder name - Adds `getGitRepoName()` function to extract repo name from git remote URL - Falls back to folder name if no remote is configured
| const crypto = require('node:crypto'); | ||
| const { loadProjectConfig } = require('./project-config'); | ||
| const { getGitRoot } = require('./git-utils'); | ||
|
|
||
| function sha256(input) { | ||
| return crypto.createHash('sha256').update(input).digest('hex').slice(0, 16); | ||
| } | ||
|
|
||
| function getGitRoot(cwd) { | ||
| try { | ||
| const gitRoot = execSync('git rev-parse --show-toplevel', { | ||
| cwd, | ||
| encoding: 'utf-8', | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }).trim(); | ||
| return gitRoot || null; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function getGitRepoName(cwd) { | ||
| try { | ||
| const remoteUrl = execSync('git remote get-url origin', { |
There was a problem hiding this comment.
Bug: The use of basePath.split('/') in src/lib/container-tag.js is not cross-platform compatible and will fail to correctly parse directory names from paths on Windows systems.
Severity: MEDIUM
Suggested Fix
Import the path module in src/lib/container-tag.js and replace basePath.split('/').pop() with path.basename(basePath) to ensure cross-platform compatibility for path manipulation.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/lib/container-tag.js#L1-L12
Potential issue: In `src/lib/container-tag.js`, the repository name is determined using
`basePath.split('/').pop()` as a fallback. On Windows, where path separators are
backslashes (`\`), this method fails. For a path like `C:\Users\user\my-repo`,
`split('/')` returns the entire string, causing the full path to be used as the
repository name. This results in malformed container tags (e.g.,
`repo_c_users_user_my_repo`) for Windows users when a git remote is not configured,
leading to inconsistent tag generation across platforms and potential validation
failures.
Did we get this right? 👍 / 👎 to inform future reviews.
| const { execSync } = require('node:child_process'); | ||
| const path = require('node:path'); | ||
|
|
||
| function getGitRoot(cwd) { | ||
| const isolateWorktrees = process.env.SUPERMEMORY_ISOLATE_WORKTREES === 'true'; | ||
|
|
||
| try { | ||
| if (isolateWorktrees) { | ||
| const gitRoot = execSync('git rev-parse --show-toplevel', { | ||
| cwd, |
There was a problem hiding this comment.
Bug: The default behavior for Git worktree handling in getGitRoot has changed, causing worktrees to share a root directory instead of being isolated. This is an undocumented breaking change.
Severity: MEDIUM
Suggested Fix
To maintain backward compatibility, the default behavior should be to isolate worktrees. The logic should be inverted so that worktree isolation is the default, and using --git-common-dir becomes the opt-in behavior, possibly controlled by a differently named environment variable.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/lib/git-utils.js#L1-L10
Potential issue: The refactored `getGitRoot` function in `src/lib/git-utils.js` changes
the default behavior for Git worktrees. Previously, each worktree was treated as an
isolated root. The new code defaults to using `--git-common-dir`, which resolves all
worktrees to the main repository's root. This undocumented breaking change means users
will have their worktree memories merged by default, losing the previous isolation. To
restore the old behavior, users must opt-in by setting the
`SUPERMEMORY_ISOLATE_WORKTREES` environment variable to 'true', which they would not
know to do.
Did we get this right? 👍 / 👎 to inform future reviews.

Use git remote URL instead of folder name for consistent repo container tags
git remote get-url originto derive repo name for container tags instead of relying solely on folder namegetGitRepoName()function to extract repo name from git remote URL