fix: correct main repo root detection for submodules (#849)
This commit is contained in:
@@ -149,8 +149,13 @@ func GetMainRepoRoot() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// The main repo root is the parent of the .git directory (commonDir)
|
||||
return filepath.Dir(ctx.commonDir), nil
|
||||
if ctx.isWorktree {
|
||||
// For worktrees, the main repo root is the parent of the shared .git directory.
|
||||
return filepath.Dir(ctx.commonDir), nil
|
||||
}
|
||||
|
||||
// For regular repos (including submodules), repoRoot is the correct root.
|
||||
return ctx.repoRoot, nil
|
||||
}
|
||||
|
||||
// GetRepoRoot returns the root directory of the current git repository.
|
||||
@@ -196,4 +201,4 @@ func NormalizePath(path string) string {
|
||||
func ResetCaches() {
|
||||
gitCtxOnce = sync.Once{}
|
||||
gitCtx = gitContext{}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user