feat(history): add Atuin context scopes
This commit is contained in:
@@ -108,6 +108,21 @@ func detectGitInfo(cwd string) (hasGit bool, branch string) {
|
||||
return hasGit, ""
|
||||
}
|
||||
|
||||
// GitRoot returns the repository root containing cwd, or an empty string.
|
||||
func GitRoot(cwd string) string {
|
||||
dir := filepath.Clean(cwd)
|
||||
for {
|
||||
if _, err := os.Stat(filepath.Join(dir, ".git")); err == nil {
|
||||
return dir
|
||||
}
|
||||
parent := filepath.Dir(dir)
|
||||
if parent == dir {
|
||||
return ""
|
||||
}
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
|
||||
type cacheEntry struct {
|
||||
key string // cwd + "|" + dirModTime
|
||||
info WorkspaceInfo
|
||||
|
||||
Reference in New Issue
Block a user