in pkg/terraform_module_ref.go [97:124]
func lookupGitPath(path string) (string, error) {
path, err := filepath.Abs(path)
if err != nil {
return "", err
}
fi, err := os.Stat(filepath.Join(path, ".git"))
if err != nil {
if !os.IsNotExist(err) {
return "", err
}
isBare, err := isBareRepo(path)
if err != nil {
return "", err
}
if isBare {
return path, nil
}
parent := filepath.Dir(path)
if parent == path {
return "", fmt.Errorf(".git not found")
}
return lookupGitPath(parent)
}
if !fi.IsDir() {
return "", fmt.Errorf(".git exist but is not a directory")
}
return filepath.Join(path, ".git"), nil
}