portedit

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 42 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package portedit prepares evaluated Portfile edits in disposable source workspaces.

Service probes literal inputs to understand calculated versions, prepares version or revision bumps and checksum refreshes, and regenerates supported dependency blocks. Archive plans cover relevant metadata contexts, preserve independent release pins, and associate checksums through macports/distfiles; the downloads themselves are macports/distfetch, and the modeled observations that judge a context and its host reads are portedit/observe. It checks the edited evaluation against the intended change and returns edits, commit intent, and fidelity diagnostics. Assessment shares the pre-download checks and reports untested stages explicitly.

Callers supply an exclusively owned workspace and retain it for the lifetime of any VersionProbe, which must be used sequentially. Git object storage, branch integration, and workflow state belong to the caller.

Index

Constants

View Source
const (
	InputFound       = "input-found"
	CandidateChecked = "candidate-checked"
	// OwnVersion is a port whose version is MacPorts' own, which update
	// leaves: it fetches nothing, and no livecheck reads its version, as
	// a _select port. It's covered, with no version input to find.
	OwnVersion  = "own-version"
	Passed      = "passed"
	Blocked     = "blocked"
	Unsupported = "unsupported"
	Unknown     = "unknown"
	NotTested   = "not-tested"
)
View Source
const ChooseMovesGitPorts = true

ChooseMovesGitPorts is the roadmap's D2: whether choose moves a port fetched with Git for its submodules to a release asset holding every one. It does, the recommended option, pending the person's pick; false leaves such a port on its clone unless --source releases asks.

Variables

View Source
var (
	ErrNotImplemented = errors.New("portedit: requested transformation is not implemented")
	ErrUnsupported    = portfile.ErrUnsupported
	ErrFidelity       = fidelity.ErrMismatch
)

Functions

This section is empty.

Types

type ArchivePair

type ArchivePair struct {
	Previous, Next distfetch.Download
	Base, Port     macports.PortInfo
}

ArchivePair is an archive an update replaced, as MacPorts shipped it, beside the archive that replaces it: what the upstream comparison reads. Base and Port are the port as the context that fetches them evaluates it, before the edit and after, whose build systems and worksrcdir are that context's.

type Assessment

type Assessment struct {
	Scope          *macports.ReleaseScope `json:",omitempty"`
	Coverage       []ContextCoverage      `json:",omitempty"`
	Contexts       []model.Platform       `json:",omitempty"`
	Outcome        string
	CurrentVersion string
	Portfile       string
	Inputs         []VersionInput
	Findings       []Finding
	Release        *model.Release `json:",omitempty"`
}

Assessment describes preparation evidence, not whether a port will build.

func (*Assessment) Summarize

func (a *Assessment) Summarize()

Summarize retains all findings; the outcome prioritizes established limitations over missing prerequisites, then uncertainty. Not-tested stages remain explicit.

type ChecksumLeft added in v0.4.0

type ChecksumLeft struct {
	Kind   LeftKind `json:"kind"`
	What   string   `json:"what"`
	Reason string   `json:"reason"`
}

ChecksumLeft is what a checksum refresh left as it was, with why: a context it couldn't model, a declaration no readable context fetches, or dependency entries it couldn't write. It's a list, not prose, so the refresh writes the rest, and later work shortens the list.

type ChecksumsToWrite

type ChecksumsToWrite struct {
	Checksums []portfile.Checksum
	Err       error
	// Agree is whether the checksums the port evaluates to already are
	// the archives', each archive's sha256, rmd160, and size among them,
	// for a refusal to say whether there's anything to change.
	Agree bool
}

ChecksumsToWrite is a checksum refresh dockhand couldn't write, with the checksums the archives MacPorts' fetch plan names have now, for a person to write: every archive of the contexts a refresh observes, a variant's own included.

func (*ChecksumsToWrite) Error

func (c *ChecksumsToWrite) Error() string

func (*ChecksumsToWrite) Unwrap

func (c *ChecksumsToWrite) Unwrap() error

type CommitIntent

type CommitIntent struct {
	Subject string
}

type ContextCoverage

type ContextCoverage struct {
	Fetch    *macports.FetchSemantics `json:",omitempty"`
	Platform model.Platform
	Modeled  bool
	// FetchesNothing is a context where the port has no archive to
	// download, as a metaport or a _select port has.
	FetchesNothing bool `json:",omitempty"`
}

ContextCoverage distinguishes metadata models from the native host. Neither kind records a build; verification providers establish build results.

type Fidelity

type Fidelity = fidelity.Report

Fidelity is the comparison report for one evaluated edit.

type Finding

type Finding struct {
	Check  string
	Status string
	Code   string
	Detail string
}

Finding has a stable check/code and a human-readable explanation.

func Problem

func Problem(check string, err error) Finding

Problem preserves typed failure distinctions without interpreting error text.

type GoToolchain

type GoToolchain struct {
	// Required is go.mod's go directive, as it writes it.
	Required string
	// Declared is the Portfile's go.toolchain_min before the update; empty
	// when it declares none.
	Declared string
	Outcome  GoToolchainOutcome
	// Problem is why go.mod couldn't be read, where Outcome is unchecked.
	Problem string `json:",omitempty"`
}

GoToolchain is the Go release a module-mode port's go.mod requires, and what the update did about the Portfile's go.toolchain_min.

type GoToolchainOutcome

type GoToolchainOutcome string

GoToolchainOutcome is what an update did about go.mod's requirement.

const (
	// GoToolchainCovered is a declared minimum already of the required
	// series, which is all the Go PortGroup compares.
	GoToolchainCovered GoToolchainOutcome = "covered"
	// GoToolchainRaised is a declared minimum dockhand raised to the
	// requirement.
	GoToolchainRaised GoToolchainOutcome = "raised"
	// GoToolchainUndeclared is a port that declares no minimum. Declaring
	// one gates the port on systems whose Go is older, which is the
	// maintainer's call.
	GoToolchainUndeclared GoToolchainOutcome = "undeclared"
	// GoToolchainByHand is a minimum below the requirement declared in a
	// way dockhand can't rewrite.
	GoToolchainByHand GoToolchainOutcome = "by hand"
	// GoToolchainUnchecked is a go.mod that couldn't be read, so the
	// minimum wasn't checked against it.
	GoToolchainUnchecked GoToolchainOutcome = "unchecked"
)

type HTTPSAnswers added in v0.7.0

type HTTPSAnswers interface {
	Ask(ctx context.Context, url string)
	Answers(ctx context.Context, url string) bool
}

HTTPSAnswers says whether URLs answer over HTTPS: Ask starts asking one, returning at once, and Answers waits for its answer. The engine's, one cache a run.

type LeftKind added in v0.4.0

type LeftKind string

LeftKind is what a ChecksumLeft is.

const (
	// LeftContext is a platform or variant the refresh couldn't read.
	LeftContext LeftKind = "context"
	// LeftDeclaration is a checksum declaration it left as written.
	LeftDeclaration LeftKind = "declaration"
	// LeftDependencies is a dependency block's entries it couldn't write.
	LeftDependencies LeftKind = "dependencies"
)

type ManifestSource

type ManifestSource interface {
	Manifest(ctx context.Context, port macports.PortInfo, release model.Release, path string) ([]byte, error)
}

ManifestSource reads one file of a port's source repository at the resolved release. An absent file reports macports.ErrManifestMissing.

type MirrorConflict added in v0.4.0

type MirrorConflict struct {
	Name   string `json:"name"`
	Subdir string `json:"subdir"`
}

MirrorConflict is an archive MacPorts' mirror already holds another file of, under a dist_subdir other ports share (distfetch.SharedMirrorCopy).

type MovedSource added in v0.8.0

type MovedSource = model.SourceMove

MovedSource is an update's move of a GitHub port's source, which the edit records (model.SourceMove).

type Override

type Override struct {
	Name, Pinned, Was, Locked string
}

Override is a registry crate a Portfile pinned at another version than its lock: Pinned over the lock's Was, which the new lock's Locked moved past.

type ProbeSource

type ProbeSource struct {
	model.EditIntent
	Source    model.Source
	Workspace *workspace.Workspace
	Selection macports.Selection
	Platform  model.Platform
}

ProbeSource selects a port in a workspace. Probing evaluates candidates as overlays of the workspace and never writes into it; it does not fetch archives.

type RefreshedPatch added in v0.7.0

type RefreshedPatch struct {
	Name  string `json:"name"`
	Words string `json:"words"`
}

RefreshedPatch is a patch the update re-emitted, and what the refresh did: "hunk 1 of src/x.c moved to where it now applies".

type Regenerated

type Regenerated struct {
	Option         string
	Count, Changed int
	// Dropped are the crates the Portfile pinned over its lock that the
	// new lock moved past, so the pins went with the rest.
	Dropped []Override `json:",omitempty"`
	// Unchecked says why the block as it was couldn't be checked against
	// the source it was made from, where it couldn't: it's regenerated
	// whole, with no override found to keep.
	Unchecked string `json:",omitempty"`
	// Notices are what the update says of the block that holds nothing:
	// Git crates the Portfile declares under a branch where the lock pins
	// them otherwise, which look unused, and cargo.update being on.
	Notices []string `json:",omitempty"`
}

Regenerated is one dependency block an update wrote again: go.vendors, cargo.crates, or cargo.crates_github, its entries, a Go module or a crate each, and those that aren't as they were.

type ReleaseFiles added in v0.8.0

type ReleaseFiles interface {
	ReleaseAssets(ctx context.Context, port macports.PortInfo, release model.Release) ([]string, error)
	SourceArchive(ctx context.Context, port macports.PortInfo, source model.GitSource, directory string) (string, error)
}

ReleaseFiles reads what choosing a GitHub port's source reads: the names of the files uploaded to its release, and the forge's archive of a commit, the tag's, which says what the repository holds there (upstream.Service).

type Request

type Request struct {
	// EditIntent is the person's choices for the edit, as bound or as
	// recorded on the job: a Stub already resolved there is honored rather
	// than resolved again.
	model.EditIntent
	Action model.EditKind
	Source model.Source
	// Workspace is the projection of the source the edit reads and never
	// writes; every candidate is an overlay of it. It is the caller's to
	// open and close, and it outlives every probe made from it.
	Workspace *workspace.Workspace
	Selection macports.Selection
	Platform  model.Platform
	Version   string
	// Subject is the commit subject after the port name; empty takes the
	// editor's default for the action, and a revision bump has none.
	Subject string
	Release *model.Release
	// KeepArchives is a directory, the caller's, where a version update
	// keeps the new archives and also fetches the current version's, so
	// the two can be compared; empty keeps neither.
	KeepArchives string
	// Stealth asks a checksum refresh to make a stealth update of an
	// archive it finds changed under the same name; nil refreshes the
	// checksums alone.
	Stealth *StealthRequest
	// HandEdit asks, where a version update is refused as an edit dockhand
	// doesn't make, for its best attempt (HandAttempt), for the person to
	// finish as their own: update --hand-edit, attended alone.
	HandEdit bool
	// Attended is an edit a person looks over before it's committed,
	// where a patch that applies only with fuzz is re-emitted for them to
	// look at in the diff; nobody's holds it (patch-fuzz), unwritten.
	Attended bool
	// SourceMode is what a version update does about a GitHub port's
	// source (chooseSource); empty chooses.
	SourceMode SourceMode

	// HTTPS answers which of the port's plain-HTTP links answer over
	// HTTPS, which the preparer (editprep) switches as part of the edit;
	// nil asks nothing and switches nothing.
	HTTPS HTTPSAnswers
	// contains filtered or unexported fields
}

func (Request) Validate

func (request Request) Validate() error

type Result

type Result struct {
	// Refused is the refusal a hand edit's attempt was written for
	// (Request.HandEdit); nil for an edit of dockhand's own.
	Refused error `json:"-"`
	// Versioned is the Portfile with its version written, where a version
	// update was refused after writing it, for a hand edit's attempt to
	// start from (HandAttempt).
	Versioned []byte                 `json:"-"`
	Scope     *macports.ReleaseScope `json:",omitempty"`
	Target    model.Target
	Files     []portfile.Edit
	Commits   []CommitIntent
	Fidelity  []Fidelity
	// Prepared is the evaluated snapshot of the prepared files, the state
	// every later step reads: the go.mod check, dependency regeneration,
	// the patch check, and the adapter's final evaluation. It is set with
	// each fidelity report, so it is the last report's snapshot without
	// any reader having to know that.
	Prepared  macports.Snapshot `json:"-"`
	Release   *model.Release
	Downloads []distfetch.Download
	// Left is what a checksum refresh left as it was, with why, and
	// Differing the archives whose checksums weren't as declared.
	Left []ChecksumLeft `json:",omitempty"`
	// ChecksumsDeclared are the archives a checksum refresh wrote a
	// declaration for, where the port declared none that covers them.
	ChecksumsDeclared []string `json:",omitempty"`
	Differing         []string `json:",omitempty"`
	// MirrorConflicts are archives MacPorts' mirror holds another file of,
	// under a dist_subdir other ports share.
	MirrorConflicts []MirrorConflict `json:",omitempty"`
	// Regenerated are the dependency blocks the update wrote again, each
	// with how many entries it has, and how many aren't as they were.
	Regenerated []Regenerated `json:",omitempty"`
	// ManifestHook is why a regenerated block, under a hook that edits
	// the manifest it's generated from, wants a look: what the hook does
	// to it couldn't be checked (R3-20). Empty otherwise.
	ManifestHook string `json:",omitempty"`
	// Pairs are each archive the update replaced beside the one that
	// replaces it, in every context that fetches them, fetched only when
	// KeepArchives asked; PreviousProblem is why the replaced ones could
	// not be, and PreviousKind its kind, which says whether another try
	// may fetch them, as HTTP and the network say (refusal.Transient): a
	// mirror's outage or a rate limit.
	Pairs           []ArchivePair `json:"-"`
	PreviousProblem string        `json:",omitempty"`
	PreviousKind    refusal.Kind  `json:",omitempty"`
	// Patches reports whether each declared patch file still applies to the
	// candidate source; a rejected patch is a finding, not a refusal.
	Patches []patchcheck.Result `json:",omitempty"`
	// Dropped are the patches the update took out, with their files,
	// since the new source already holds them.
	Dropped []string `json:",omitempty"`
	// Refreshed are the patches the update re-emitted to apply as written
	// to the new source, each with what it did (refreshPatches).
	Refreshed []RefreshedPatch `json:",omitempty"`
	// GoToolchain is what a module-mode port's go.mod requires, and what
	// the update did about the Portfile's go.toolchain_min; nil where no
	// go.mod was read.
	GoToolchain *GoToolchain `json:",omitempty"`
	// Stealth is the stealth update a checksum refresh found and made; nil
	// when it found none, or wasn't asked (Request.Stealth).
	Stealth *Stealth `json:",omitempty"`
	// DistSubdirRemoved is true when a version update removed the
	// dist_subdir an earlier stealth update set.
	DistSubdirRemoved bool `json:",omitempty"`
	// SourceMoved is a version update's move of a GitHub port's source,
	// from GitHub's tarball, its archive, or a Git clone to a release's
	// own file or GitHub's archive (chooseSource); nil where it moved
	// none. SourceNotice says why a source that could move didn't, where
	// one didn't: "release 2.5.0 carries mindforger-2.5.0.tar.gz, which
	// lacks deps/cmark-gfm, so the port stays on its clone".
	SourceMoved  *MovedSource `json:",omitempty"`
	SourceNotice string       `json:",omitempty"`
	// Unchanged is the port as it stands where nothing was edited, as for
	// an update to the version it already has: what it is at, which no
	// fidelity report says then. Nil when there was an edit.
	Unchanged *macports.PortInfo `json:"-"`
}

func (Result) PortAfter

func (r Result) PortAfter(name string) (macports.PortInfo, bool)

PortAfter is a port as the edit leaves it: the prepared files' evaluation, which the last fidelity report's is, or, where nothing was edited, as it stands; false where the result says neither. Its readers needn't know which of those the result holds (the helper-ownership review's table).

func (Result) PortBefore

func (r Result) PortBefore(name string) (macports.PortInfo, bool)

PortBefore is a port as the edit found it: the first evaluation's, or, where nothing was edited, as it stands; false where the result says neither.

type Service

type Service struct {
	DependencyTools depblock.Tools
	// PatchTools are the diff and patch a port's patches are checked with.
	PatchTools patchcheck.Tools
	Ports      macports.Evaluator
	// Archives fetches source archives; its zero value downloads with the
	// default client and limits.
	Archives distfetch.Client
	// Manifests reads a manifest from the resolved release's repository, for
	// a git-fetched port that downloads no archive to read it from; nil
	// leaves such a port's toolchain minimum as declared.
	Manifests ManifestSource
	// Releases lists a GitHub release's files and reads the forge's
	// archive of its tag, for choosing a port's source; nil chooses none.
	Releases ReleaseFiles
}

func (*Service) HandAttempt added in v0.6.0

func (s *Service) HandAttempt(ctx context.Context, request Request, refused Result) (_ Result, err error)

HandAttempt is dockhand's best attempt at a version update it refused, for a person to finish by hand (update --hand-edit, Then's item 3): the refused edit where the refusal came with one, as strict fidelity's does, else the version written as its one literal; its revision reset where that can be; and its checksums refreshed for the new version's archives where they can be. What couldn't be done is in Left, with why. It's no edit of dockhand's own, whose fidelity is proven: the person takes it as theirs.

func (*Service) Prepare

func (s *Service) Prepare(ctx context.Context, request Request) (_ Result, err error)

func (*Service) Probe

func (s *Service) Probe(ctx context.Context, source ProbeSource) (*VersionProbe, error)

type SourceMode added in v0.8.0

type SourceMode string

SourceMode is what a version update does about a GitHub port's source (update --source, [update] source, whose values config.UpdateSources lists): suggest, the default, leaves it as it is, but for a tarball port's move to GitHub's archive, and says where a release's own file is the source; choose moves to a release's own file where one is the source; keep leaves the source as it is; or ask for a release's file or GitHub's archive of the tag, refused where it doesn't qualify.

const (
	SourceSuggest  SourceMode = "suggest"
	SourceChoose   SourceMode = "choose"
	SourceKeep     SourceMode = "keep"
	SourceReleases SourceMode = "releases"
	SourceArchive  SourceMode = "archive"
)

type Stealth

type Stealth struct {
	Distfiles []StealthDistfile
	// Revbumped is true when the revision was bumped, since the source
	// changed; RevbumpProblem says why it could not be, when asked.
	Revbumped      bool
	RevbumpProblem string
	// DistSubdir is where mirrors now keep the new archive, as evaluated,
	// such as croc/10.2.4_1; empty when it was not set, and Problem says
	// why.
	DistSubdir string
	Problem    string
	// Unchanged is true where each archive's tree is the one MacPorts
	// shipped, file for file: only its packaging differs, and nothing is
	// revbumped. Differ are the files that differ where one doesn't, a
	// few; CompareProblem why the shipped archive couldn't be compared
	// (the docs dig's I19).
	Unchanged      bool
	Differ         []string
	CompareProblem string
}

Stealth is the stealth update a checksum refresh found and made, as its final evaluation shows it.

type StealthDistfile

type StealthDistfile struct {
	Name     string
	Was, Now portfile.Checksum
}

StealthDistfile is one archive's checksums before and after.

type StealthRequest

type StealthRequest struct {
	Changed      []string
	KeepRevision bool
	Base         *macports.PortInfo
}

StealthRequest asks a checksum refresh to treat an archive whose contents changed upstream under the same name as a stealth update (Design v3 §6.5): the revision bumped, since the source changed, unless KeepRevision, and dist_subdir set so mirrors keep both archives. Changed are the files the branch has changed since its base, which the caller knows, and Base the port as the base evaluates it, where Changed names its Portfile: a version edited by hand since, as for a new version, makes the refresh no stealth update, while a comment or a homepage edited leaves it one (the update-workflow review's efficiency note). Base is nil where the base has no such port, or it couldn't be evaluated, and a Portfile changed then is taken as a new version.

type VersionInput

type VersionInput struct {
	Line, Column int
	Value        string
}

VersionInput locates a literal candidate in the original committed Portfile. Its presence alone does not establish that any particular release is editable.

type VersionProbe

type VersionProbe struct {
	// contains filtered or unexported fields
}

VersionProbe binds source metadata and candidate evaluation to one workspace. Callers must keep the workspace alive and use the probe sequentially.

func (*VersionProbe) Agrees

func (p *VersionProbe) Agrees(indexed string) error

Agrees checks that the probe evaluated the port an index named, for a caller that selected ports by their indexed names. A stub is the one legitimate difference: the index names the stub, py-black, and the probe redirects to the subport carrying its release, py313-black, so that is the port evaluated. Any other difference means evaluation settled on a port the index didn't name, which isn't one the caller can vouch for.

func (*VersionProbe) Assess

func (p *VersionProbe) Assess(ctx context.Context, release *model.Release) (Assessment, error)

Assess checks declarations and optional candidate fidelity without downloading archives or executing dependency generators. It restores each temporary edit.

func (*VersionProbe) CheckRelease

func (p *VersionProbe) CheckRelease(ctx context.Context, release model.Release) error

CheckRelease applies the stricter edit-fidelity checks after release selection.

func (*VersionProbe) Close

func (p *VersionProbe) Close() error

Close ends the probe's interpreter session. Callers close a probe when they are done with it, as they close the workspace it was bound to.

func (*VersionProbe) EvaluateVersion

func (p *VersionProbe) EvaluateVersion(ctx context.Context, value string) (string, error)

EvaluateVersion reports the calculated port version without requiring that the candidate is suitable for an automatic edit. Editing fidelity is checked separately.

func (*VersionProbe) EvaluateVersions

func (p *VersionProbe) EvaluateVersions(ctx context.Context, values []string) ([]string, error)

EvaluateVersions reports the calculated port version for each source version in order, through the probe's shared interpreter session; the evaluation itself is unchanged. An error names the value that failed.

func (*VersionProbe) Observations added in v0.8.0

func (p *VersionProbe) Observations(ctx context.Context, observed func(model.Platform, macports.Observation, error)) error

Observations observes the port as committed in each context an assessment observes its archives in, with its declarations, and hands each context's observation, or why it couldn't be had, to observed; the assessment reuses them. A survey records them (tools/survey). Without the contexts, it says why.

func (*VersionProbe) Port

func (p *VersionProbe) Port() macports.PortInfo

func (*VersionProbe) Versions added in v0.8.0

func (p *VersionProbe) Versions() macports.VersionSession

Versions compares versions in the probe's interpreter, where it has one that can (macports.VersionBatch), so a discovery bound to the probe starts none of its own; nil otherwise. The probe's Close ends it.

Directories

Path Synopsis
Package observe runs a Portfile's contents through MacPorts in modeled contexts and judges what the evaluation depended on.
Package observe runs a Portfile's contents through MacPorts in modeled contexts and judges what the evaluation depended on.

Jump to

Keyboard shortcuts

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