示例#1
0
文件: kmgGit.go 项目: keysonZZZ/kmg
func MustGetRepositoryFromPath(path string) (repo *Repository) {
	p, err := kmgFile.SearchFileInParentDir(path, ".git")
	if err != nil {
		panic(err)
	}
	return &Repository{
		gitPath: p,
	}
}
示例#2
0
文件: kmgGit.go 项目: keysonZZZ/kmg
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
文件: Env.go 项目: keysonZZZ/kmg
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
}