Skip to content

Use git remote URL for repo container tags#28

Merged
Dhravya merged 1 commit intomainfrom
use-git-remote-for-repo-tag
Feb 12, 2026
Merged

Use git remote URL for repo container tags#28
Dhravya merged 1 commit intomainfrom
use-git-remote-for-repo-tag

Conversation

@Prasanna721
Copy link
Member

@Prasanna721 Prasanna721 commented Feb 12, 2026

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

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
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Prasanna721 Prasanna721 self-assigned this Feb 12, 2026
@Prasanna721 Prasanna721 requested a review from Dhravya February 12, 2026 04:14
@Prasanna721 Prasanna721 marked this pull request as ready for review February 12, 2026 04:14
@Dhravya Dhravya merged commit e4334e9 into main Feb 12, 2026
3 checks passed
Comment on lines 2 to 12
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', {
Copy link

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('/') 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.

Comment on lines +1 to +10
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,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants