示例#1
0
文件: proj.go 项目: e8vm/shanhu
func projDat(db repodb.DB, c *context, route *repoRoute) (
	interface{}, error,
) {
	repo := route.Repo()

	b, err := db.LatestBuild(repo)
	if err != nil {
		return nil, err
	}

	type d struct {
		GoImport string
		UserInfo *userInfo
		Repo     string
		RepoUser string
		RepoName string
		Dirs     []string
		Commit   string
		Proj     template.JS
	}

	return &d{
		GoImport: route.goImportMeta(),
		UserInfo: newUserInfo(c),
		Repo:     repo,
		RepoUser: route.owner,
		RepoName: route.repo,
		Commit:   shortCommit(b.Build),
		Proj:     template.JS(string(b.Struct)),
	}, nil
}
示例#2
0
文件: repo.go 项目: e8vm/shanhu
// UpdateDB updates the repository in the database.
func UpdateDB(db repodb.DB, path string) []error {
	if err := GitPull(path); err != nil {
		return []error{fmt.Errorf("git pull: %s", err)}
	}

	b, errs := Build(path)
	if len(errs) > 0 {
		return errs
	}

	if err := db.AddBuild(b); err != nil {
		return []error{err}
	}
	return nil
}
示例#3
0
文件: file.go 项目: e8vm/shanhu
func fileDat(db repodb.DB, c *context, route *repoRoute) (
	interface{}, error,
) {
	if route.file == "" {
		return nil, fmt.Errorf("%q is not a file", route.fullPath)
	}

	repo := route.Repo()
	f, err := db.LatestFile(repo, route.fullPath)
	if err != nil {
		return nil, err
	}

	var fc repodb.File
	if err := json.Unmarshal(f.Content, &fc); err != nil {
		return nil, err
	}

	type d struct {
		GoImport string
		UserInfo *userInfo
		Repo     string
		RepoUser string
		RepoName string
		Dirs     []string
		FileName string
		Commit   string

		Nline int
		File  template.HTML
	}

	return &d{
		GoImport: route.goImportMeta(),
		UserInfo: newUserInfo(c),
		Repo:     repo,
		RepoUser: route.owner,
		RepoName: route.repo,
		Dirs:     route.dirs,
		FileName: route.file,
		Commit:   shortCommit(f.Build),
		Nline:    fc.Nline,
		File:     template.HTML(string(fc.HTML)),
	}, nil
}