예제 #1
0
파일: grapher.go 프로젝트: xuy/srclib
// NormalizeData sorts data and performs other postprocessing.
func NormalizeData(unitType, dir string, o *graph.Output) error {
	for _, ref := range o.Refs {
		if ref.DefRepo != "" && ref.DefRepo != unit.UnitRepoUnresolved {
			uri, err := graph.TryMakeURI(string(ref.DefRepo))
			if err != nil {
				return err
			}
			ref.DefRepo = uri
		}
		if ref.Repo != "" && ref.DefRepo != unit.UnitRepoUnresolved {
			uri, err := graph.TryMakeURI(string(ref.Repo))
			if err != nil {
				return err
			}
			ref.Repo = uri
		}
	}

	if unitType != "GoPackage" && unitType != "Dockerfile" && unitType != "BashDirectory" && unitType != "ManPages" {
		ensureOffsetsAreByteOffsets(dir, o)
	}

	if err := ValidateRefs(o.Refs); err != nil {
		return err
	}
	if err := ValidateDefs(o.Defs); err != nil {
		return err
	}
	if err := ValidateDocs(o.Docs); err != nil {
		return err
	}

	sortedOutput(o)
	return nil
}
예제 #2
0
파일: repo_config.go 프로젝트: abec/srclib
// URI returns the Repo's URI. It returns the empty string if the
// Repo's CloneURL is malformed or empty.
func (c *Repo) URI() string {
	if uri, err := graph.TryMakeURI(c.CloneURL); err != nil {
		return ""
	} else {
		return uri
	}
}
예제 #3
0
// NormalizeData sorts data and performs other postprocessing.
func NormalizeData(currentRepoURI, unitType, dir string, o *graph.Output) error {
	for _, ref := range o.Refs {
		if ref.DefRepo == currentRepoURI {
			ref.DefRepo = ""
		}
		if ref.DefRepo != "" {
			uri, err := graph.TryMakeURI(string(ref.DefRepo))
			if err != nil {
				return err
			}
			ref.DefRepo = uri
		}
		if ref.Repo == currentRepoURI {
			ref.Repo = ""
		}
		if ref.Repo != "" {
			uri, err := graph.TryMakeURI(string(ref.Repo))
			if err != nil {
				return err
			}
			ref.Repo = uri
		}
	}

	if unitType != "GoPackage" && unitType != "Dockerfile" && unitType != "NugetPackage" {
		ensureOffsetsAreByteOffsets(dir, o)
	}

	if err := ValidateRefs(o.Refs); err != nil {
		return err
	}
	if err := ValidateDefs(o.Defs); err != nil {
		return err
	}
	if err := ValidateDocs(o.Docs); err != nil {
		return err
	}

	sortedOutput(o)
	return nil
}
예제 #4
0
func (p *pkgInfo) SourceUnit() *unit.SourceUnit {
	repoURI, err := graph.TryMakeURI(p.RepoURL)
	if err != nil {
		log.Printf("Could not make repo URI from %s: %s", p.RepoURL, err)
		repoURI = ""
	}
	return &unit.SourceUnit{
		Name:         p.ProjectName,
		Type:         DistPackageSourceUnitType,
		Repo:         repoURI,
		Dir:          p.RootDir,
		Dependencies: nil, // nil, because scanner does not resolve dependencies
		Ops:          map[string]*srclib.ToolRef{"depresolve": nil, "graph": nil},
	}
}
예제 #5
0
// URI returns the Repo's URI. It returns the empty string if the
// Repo's CloneURL is malformed or empty.
func (c *Repo) URI() string {
	uri, _ := graph.TryMakeURI(c.CloneURL)
	return uri
}