-
Notifications
You must be signed in to change notification settings - Fork 149
Use git remote URL for repo container tags #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| 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, | ||
|
Comment on lines
+1
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The default behavior for Git worktree handling in Suggested FixTo 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 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| encoding: 'utf-8', | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }).trim(); | ||
| return gitRoot || null; | ||
| } | ||
|
|
||
| const gitCommonDir = execSync('git rev-parse --git-common-dir', { | ||
| cwd, | ||
| encoding: 'utf-8', | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }).trim(); | ||
|
|
||
| if (gitCommonDir === '.git') { | ||
| const gitRoot = execSync('git rev-parse --show-toplevel', { | ||
| cwd, | ||
| encoding: 'utf-8', | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }).trim(); | ||
| return gitRoot || null; | ||
| } | ||
|
|
||
| const resolved = path.resolve(cwd, gitCommonDir); | ||
|
|
||
| if ( | ||
| path.basename(resolved) === '.git' && | ||
| !resolved.includes(`${path.sep}.git${path.sep}`) | ||
| ) { | ||
| return path.dirname(resolved); | ||
| } | ||
|
|
||
| const gitRoot = execSync('git rev-parse --show-toplevel', { | ||
| cwd, | ||
| encoding: 'utf-8', | ||
| stdio: ['pipe', 'pipe', 'pipe'], | ||
| }).trim(); | ||
| return gitRoot || null; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| module.exports = { getGitRoot }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The use of
basePath.split('/')insrc/lib/container-tag.jsis not cross-platform compatible and will fail to correctly parse directory names from paths on Windows systems.Severity: MEDIUM
Suggested Fix
Import the
pathmodule insrc/lib/container-tag.jsand replacebasePath.split('/').pop()withpath.basename(basePath)to ensure cross-platform compatibility for path manipulation.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.