Documentation
¶
Overview ¶
Package dependents finds and ranks repositories that depend on a package.
Index ¶
- Constants
- func DefaultScore(candidate Candidate) int64
- func Filter(candidates []Candidate, opts FilterOptions) ([]Candidate, []Rejection)
- func PopularityScore(candidate Candidate) int64
- type Analysis
- type AnalysisFailure
- type AnalysisResult
- type AnalyzeOptions
- type CacheCheckout
- type Candidate
- func Build(groups []Group) []Candidate
- func BuildEnrichmentCandidates(groups []enrichment.RepositoryDependents) []Candidate
- func DiscoverRepository(ctx context.Context, client RepositoryDependentsClient, repository string, ...) ([]Candidate, error)
- func ExcludeRepositories(candidates []Candidate, repositories ...string) []Candidate
- func Rank(candidates []Candidate, limit int, scorer ScoreFunc) []Candidate
- type Checkout
- type CheckoutFunc
- type CloneCheckout
- type Dependent
- type DiscoverOptions
- type FilterOptions
- type Group
- type NativeExtension
- type Package
- type PackageRef
- type Rejection
- type Relationship
- type RepositoryDependentsClient
- type RepositoryMetadata
- type ScoreFunc
Constants ¶
const ( DefaultMaxPackages = 25 DefaultMaxDependentsPerPackage = 30 )
const ( ReasonFork = "fork" ReasonArchived = "archived" ReasonMirror = "mirror" ReasonStale = "stale" ReasonNotAnalyzed = "not analyzed" ReasonNoTests = "no tests" ReasonNoImports = "no upstream references" )
Variables ¶
This section is empty.
Functions ¶
func DefaultScore ¶
DefaultScore favors repositories with source references and tests after analysis, with popularity as a tiebreaker. Before analysis it returns the popularity score.
func Filter ¶
func Filter(candidates []Candidate, opts FilterOptions) ([]Candidate, []Rejection)
Filter applies repository health policy without changing candidates.
func PopularityScore ¶
PopularityScore returns registry downloads when available and otherwise uses dependent repository count.
Types ¶
type Analysis ¶
type Analysis struct {
TestFiles int
ImportFiles int
NativeExtensions []NativeExtension
}
Analysis contains checkout-derived ranking signals and integrations.
type AnalysisFailure ¶
AnalysisFailure records one candidate that could not be checked out or scanned. The candidate remains in AnalysisResult.Candidates unchanged.
type AnalysisResult ¶
type AnalysisResult struct {
Candidates []Candidate
Failures []AnalysisFailure
}
AnalysisResult contains every candidate and any per-repository failures.
func Analyze ¶
func Analyze(ctx context.Context, candidates []Candidate, opts AnalyzeOptions) (AnalysisResult, error)
Analyze checks out and scans each candidate. Individual repository failures are collected without stopping the remaining candidates.
type AnalyzeOptions ¶
type AnalyzeOptions struct {
Upstreams []string
Workdir string
Checkout Checkout
Keep bool
DetectNativeExtensions bool
}
AnalyzeOptions controls checkout analysis.
type CacheCheckout ¶
CacheCheckout prepares job-local copies through a git-pkgs/clone cache.
type Candidate ¶
type Candidate struct {
Repository string
Packages []Package
Upstreams []PackageRef
Relationships []Relationship
RepositoryMetadata RepositoryMetadata
Downloads int64
DependentRepos int
Analysis Analysis
Analyzed bool
Commit string
Directory string
}
Candidate is one repository containing packages that depend on one or more upstream packages. Packages and Upstreams are deduplicated and sorted.
func Build ¶
Build combines dependent packages by repository. Popularity values use the maximum reported by any package in the repository so a monorepo is not rewarded merely for publishing more packages.
func BuildEnrichmentCandidates ¶
func BuildEnrichmentCandidates(groups []enrichment.RepositoryDependents) []Candidate
BuildEnrichmentCandidates converts enrichment results into repository-level candidates.
func DiscoverRepository ¶
func DiscoverRepository(ctx context.Context, client RepositoryDependentsClient, repository string, opts DiscoverOptions) ([]Candidate, error)
DiscoverRepository fetches dependent packages for repository and combines packages from the same dependent repository into one candidate.
func ExcludeRepositories ¶
ExcludeRepositories returns a copy without candidates whose canonical repository URL appears in repositories.
type CheckoutFunc ¶
CheckoutFunc adapts a function to Checkout.
type CloneCheckout ¶
CloneCheckout prepares shallow checkouts with git-pkgs/clone. Set Full for full history or Ref to select a branch, tag, or commit.
type Dependent ¶
type Dependent struct {
Package
Repository string
RepositoryMetadata RepositoryMetadata
}
Dependent associates a package with the repository that publishes it.
type DiscoverOptions ¶
DiscoverOptions bounds the packages and dependents fetched from enrichment.
type FilterOptions ¶
type FilterOptions struct {
ExcludeForks bool
ExcludeArchived bool
ExcludeMirrors bool
MaxAge time.Duration
Now time.Time
RequireAnalyzed bool
RequireTests bool
RequireImports bool
}
FilterOptions lets each consumer choose its repository eligibility policy. A zero MaxAge does not filter stale repositories. Missing push dates are retained.
type Group ¶
type Group struct {
Upstream PackageRef
Dependents []Dependent
}
Group contains the packages that depend on one upstream package.
type NativeExtension ¶ added in v0.2.0
NativeExtension describes a detected native-extension toolchain.
type Package ¶
type Package struct {
Name string
Ecosystem string
PURL string
RegistryURL string
LatestVersion string
Downloads int64
DependentRepos int
}
Package describes a dependent package published from a candidate repository.
type PackageRef ¶
PackageRef identifies a package published by the repository whose dependents are being discovered.
type Relationship ¶
type Relationship struct {
Upstream PackageRef
Dependent PackageRef
}
Relationship records one package-level dependency edge inside a candidate repository.
type RepositoryDependentsClient ¶
type RepositoryDependentsClient interface {
GetDependentsByRepositoryURL(context.Context, string, int, int) ([]enrichment.RepositoryDependents, error)
}
RepositoryDependentsClient is implemented by enrichment.EcosystemsClient.