dep

package
v0.1.7-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package dep defines the working dependency types shared between the resolver and the lockfile.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Old Dependency
	New Dependency
}

Change pairs an old and new dependency that represent the same logical action across a lockfile update. Both fields are always populated.

type Dependency

type Dependency struct {
	NWO string // owner/repo (no path)
	// Path is the optional sub-action subpath as written in `uses:`
	// (e.g. "save" for actions/cache/save). It is preserved on the
	// in-memory dep so resolver-time graph traversal can fetch the
	// correct sub-action.yml, but it is NOT part of the lockfile pin
	// identity (the runner downloads at repo+sha granularity) and is
	// dropped at serialization time. Distinct subpaths in the same
	// repo+ref collapse to one lockfile entry.
	Path     string
	Ref      string // resolved ref as given in uses:
	SHA      string // full commit hash
	HashAlgo string // "sha1" or "sha256"
	// Tag is the discovered release/tag pointing at SHA, if any. Optional.
	// Populated by the pin-time discovery pass; not read from `uses:`.
	Tag string
	// Branch is the discovered branch containing SHA. Optional. Populated
	// by the pin-time discovery pass. Used for branch-hint seeding and
	// resolver caches; serialized as the lockfile `ref` when no tag exists.
	Branch string
}

Dependency is the resolver's in-memory view of a single pinned action: the lockfile-grammar pin (NWO@Ref:Algo-SHA) plus the discovered Tag / Branch / sub-action Path. It is the working shape between `uses:` parsing, resolver traversal, and lockfile serialization — never persisted on disk and not part of any public API.

func Dedup

func Dedup(deps []Dependency) []Dependency

Dedup returns a copy of deps with duplicates (by Key) removed, preserving first-seen order.

func PreserveRefs

func PreserveRefs(old, new []Dependency) []Dependency

PreserveRefs keeps existing human-readable refs for deps whose SHA hasn't changed. When re-resolving transitive deps, the parent action.yml often provides a bare SHA as the ref, losing the tag we already have in the lockfile. This restores it.

func (Dependency) FullName

func (d Dependency) FullName() string

FullName returns owner/repo or owner/repo/path.

func (Dependency) HashAlgoOrDetect

func (d Dependency) HashAlgoOrDetect() string

HashAlgoOrDetect returns the hash algorithm, falling back to detection from SHA length.

func (Dependency) Key

func (d Dependency) Key() string

Key returns the dependency key for deduplication: NWO@Ref.

func (Dependency) OwnerRepo

func (d Dependency) OwnerRepo() (string, string)

OwnerRepo splits NWO into owner and repo components.

func (Dependency) String

func (d Dependency) String() string

String formats the dependency using the canonical pin form.

type Diff

type Diff struct {
	Changed   []Change     // Same Key, SHA differs
	Rekeyed   []Change     // Same NWO, different ref (tag moved)
	Added     []Dependency // In new but not old (no NWO match)
	Removed   []Dependency // In old but not new
	Unchanged []Dependency // Same Key, same SHA
}

Diff is the result of comparing two dependency lists.

Matching strategy:

  1. Exact key match (NWO@Ref) — produces Changed (SHA differs) or Unchanged.
  2. Fuzzy NWO match — unmatched deps with the same NWO are paired preferring same-SHA first, then stable order. These appear in Rekeyed (the ref changed but it's the same logical dependency).
  3. Remaining unmatched new deps go to Added.
  4. Remaining unmatched old deps go to Removed.

Ordering: Changed, Rekeyed, and Unchanged preserve new-list order. Added preserves new-list order. Removed preserves old-list order.

func DiffDeps

func DiffDeps(old, new []Dependency) Diff

DiffDeps computes a structured diff between old and new dependency lists. If duplicate keys exist within a list, last-wins for exact matching.

type ParentMap

type ParentMap map[string][]string

ParentMap is a child dep key → parent dep keys mapping returned alongside resolved dependencies by ResolveAllRecursive. It is value-typed so callers can hold their own copy across concurrent calls without racing on resolver state.

func RekeyParentMap

func RekeyParentMap(pm ParentMap, rewrites map[string]string) ParentMap

RekeyParentMap returns a new ParentMap with both child keys and parent values rewritten according to rewrites (e.g. tag narrowing v4 → v4.3.1, or ReverseLookup replacing a SHA with a discovered tag). The input is not mutated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL