WIP: operator collaboration MVP

See toolshed/organising#467
This commit is contained in:
2024-12-30 00:46:25 +01:00
parent 74108b0dd9
commit 4d7c812fe2
13 changed files with 319 additions and 20 deletions

35
pkg/git/dir.go Normal file
View File

@ -0,0 +1,35 @@
package git
import (
"os"
"path"
"path/filepath"
"coopcloud.tech/abra/pkg/log"
)
func FindDir(dir string) string {
dir, err := filepath.Abs(dir)
if err != nil {
return ""
}
realPath, err := filepath.EvalSymlinks(dir)
if err != nil {
log.Warn("unable to find git repo: broken symlink: %s", dir)
return ""
}
dir = realPath
if dir == os.ExpandEnv("$HOME/.abra") || dir == os.ExpandEnv("$ABRA_DIR") || dir == "/" {
return ""
}
p := path.Join(dir, ".git")
if _, err := os.Stat(p); err == nil {
return path.Dir(p)
}
return FindDir(filepath.Dir(dir))
}