func MustGetRepositoryFromPath(path string) (repo *Repository) { p, err := kmgFile.SearchFileInParentDir(path, ".git") if err != nil { panic(err) } return &Repository{ gitPath: p, } }
func GetRepositoryFromPath(path string) (repo *Repository, err error) { p, err := kmgFile.SearchFileInParentDir(path, ".git") if err != nil { if err == kmgFile.NotFoundError { return nil, errors.New("can not found .git folder,do you in a git repository?") } return } return &Repository{ gitPath: p, }, nil }
func FindFromPath(p string) (context *Env, err error) { p, err = kmgFile.SearchFileInParentDir(p, ".kmg.yml") if err != nil { return } kmgFilePath := filepath.Join(p, ".kmg.yml") context = &Env{} err = kmgYaml.ReadFile(kmgFilePath, context) if err != nil { return } context.ProjectPath, err = filepath.Abs(filepath.Dir(kmgFilePath)) if err != nil { return } context.Init() return }