func fillPackageInfo(p *gcse.Package, pi *stpb.PackageInfo) { pi.Package = p.Package pi.Name = p.Name pi.Synopsis = p.Synopsis pi.Description = p.Doc pi.Author = gcse.AuthorOfPackage(p.Package) pi.ProjectUrl = p.ProjectURL pi.Stars = int32(p.StarCount) pi.ReadmeFn = p.ReadmeFn pi.ReadmeData = p.ReadmeData pi.Exported = p.Exported pi.References = p.References pi.Imports = nil for _, imp := range p.Imports { if doc.IsValidRemotePath(imp) { pi.Imports = append(pi.Imports, imp) } } pi.TestImports = nil for _, imp := range p.TestImports { if doc.IsValidRemotePath(imp) { pi.TestImports = append(pi.TestImports, imp) } } }
func packageToDoc(p *gcse.Package) gcse.DocInfo { // copy Package as a DocInfo d := gcse.DocInfo{ Package: p.Package, Name: p.Name, Synopsis: p.Synopsis, Description: p.Doc, LastUpdated: time.Now(), Author: gcse.AuthorOfPackage(p.Package), ProjectURL: p.ProjectURL, StarCount: p.StarCount, ReadmeFn: p.ReadmeFn, ReadmeData: p.ReadmeData, Exported: p.Exported, } d.Imports = nil for _, imp := range p.Imports { if doc.IsValidRemotePath(imp) { d.Imports = append(d.Imports, imp) } } d.TestImports = nil for _, imp := range p.TestImports { if doc.IsValidRemotePath(imp) { d.TestImports = append(d.TestImports, imp) } } // append new authors if strings.HasPrefix(d.Package, "github.com/") { cDB.AppendPerson("github.com", d.Author) } else if strings.HasPrefix(d.Package, "bitbucket.org/") { cDB.AppendPerson("bitbucket.org", d.Author) } for _, imp := range d.Imports { appendPackage(imp) } for _, imp := range d.TestImports { appendPackage(imp) } log.Printf("[pushPackage] References: %v", p.References) for _, ref := range p.References { appendPackage(ref) } schedulePackageNextCrawl(d.Package, p.Etag) return d }