fix(init): prevent parent hub contamination during bd init (GH#896)
When running bd init in a subdirectory of a hub (e.g., ~/Repos/project where ~/Repos/.beads exists), the new database was incorrectly inheriting issues from the parent hub. Root cause: checkGitForIssues() computed the relative path from gitRoot to beadsDir but did not validate that beadsDir was actually inside the git repository. When beadsDir was outside (e.g., ../.beads), it would still attempt to import, causing contamination. Fix: Add a guard to reject beadsDir paths that start with .. (outside the git repository boundary). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
9d69099803
commit
b3ebedb063
@@ -118,6 +118,13 @@ func checkGitForIssues() (int, string, string) {
|
||||
return 0, "", ""
|
||||
}
|
||||
|
||||
// GH#896: Reject beadsDir that is outside the git repository.
|
||||
// This prevents bd init from inheriting issues from a parent hub
|
||||
// when initializing a new project in a subdirectory.
|
||||
if strings.HasPrefix(relBeads, "..") {
|
||||
return 0, "", ""
|
||||
}
|
||||
|
||||
// Determine which branch to read from (bd-0is fix)
|
||||
// If sync-branch is configured in local config.yaml, use it; otherwise fall back to HEAD
|
||||
// We read sync-branch directly from local config file rather than using cached global config
|
||||
|
||||
Reference in New Issue
Block a user