Esempio n. 1
0
func (p *project) build() {
	p.lock.Lock()
	defer p.lock.Unlock()
	p.clear()

	// clear the saving slots
	pkgs, e := goload.ListPkgs(p.path)
	if p.err(e) {
		log.Printf("error: %s", e)
		return
	}
	pkgDep := p.buildPkgDep(pkgs)

	var fileDeps map[string]interface{}
	var files map[string]*repodb.File

	prog, e := goload.Pkgs(pkgs)
	if !p.err(e) {
		fileDeps = p.buildFileDeps(prog)

		var es []error
		files, es = goview.Files(prog)
		p.err(es...)
	}

	p.setPage("INDEX", p.jsonObj(pkgDep))
	for pkg, dep := range fileDeps {
		pkg, e = p.trimPath(pkg)
		if p.err(e) {
			continue
		}
		p.setPage(pkg, p.jsonObj(dep))
	}

	for path, f := range files {
		path, e := p.trimPath(path)
		if p.err(e) {
			continue
		}
		p.setPage(path, f.HTML)
	}

	for _, e := range p.errs {
		log.Printf("error: %s", e)
	}
}
Esempio n. 2
0
File: repo.go Progetto: e8vm/shanhu
// Build builds a repo into a repodb build.
func Build(path string) (*repodb.Build, []error) {
	// this will also check if it is in a git repo
	buildHash, err := GitCommitHash(path)
	if err != nil {
		return nil, []error{err}
	}

	r, err := newRepo(path)
	if err != nil {
		return nil, []error{err}
	}

	deps := new(repodb.Deps)

	deps.Pkgs, err = r.pkgDeps()
	if err != nil {
		return nil, []error{err}
	}

	var errs []error
	deps.Files, errs = r.fileDeps()
	if len(errs) > 0 {
		return nil, errs
	}

	files, errs := goview.Files(r.prog)
	if len(errs) > 0 {
		return nil, errs
	}

	return &repodb.Build{
		Name:  path,
		Build: buildHash,
		Lang:  "go",
		Deps:  deps,
		Files: files,
	}, nil
}