Пример #1
0
func MustGetRepositoryFromPath(path string) (repo *Repository) {
	p, err := kmgFile.SearchFileInParentDir(path, ".git")
	if err != nil {
		panic(err)
	}
	return &Repository{
		gitPath: p,
	}
}
Пример #2
0
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
}
Пример #3
0
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
}