Use lazycore utils: Clamp and GetLazyRootDirectory

This commit is contained in:
Gustavo Andrioli 2022-10-15 13:47:55 -03:00
parent 05089b9a9a
commit 39e84e13f4
11 changed files with 61 additions and 43 deletions

View file

@ -135,30 +135,3 @@ func FilePath(skip int) string {
_, path, _, _ := runtime.Caller(skip)
return path
}
// for our cheatsheet script and integration tests. Not to be confused with finding the
// root directory of _any_ random repo.
func GetLazygitRootDirectory() string {
path, err := os.Getwd()
if err != nil {
panic(err)
}
for {
_, err := os.Stat(filepath.Join(path, ".git"))
if err == nil {
return path
}
if !os.IsNotExist(err) {
panic(err)
}
path = filepath.Dir(path)
if path == "/" {
log.Fatal("must run in lazygit folder or child folder")
}
}
}