Documentation
¶
Overview ¶
Package commitrules checks commits against what MacPorts asks of them (Design v3 §8): subjects that name the port, short and specific; bodies wrapped at 72; tickets as full URLs; no follow-up or merge commits; a revision reset to 0 when the version changes, an epoch raised when it goes lower, by MacPorts' version order the caller gives (Order), and a replaced_by that changes the version, revision, or epoch. tidy writes by these rules, and submit's preview applies them. The rules that need MacPorts to run (lint) or GitHub (other open pull requests, maintainers) are not here.
Index ¶
- Constants
- func Codes() []string
- func ErrorCodes() []string
- func Errors(findings []Finding) bool
- type Commit
- type Evaluate
- type Explanation
- type Finding
- func CheckCommits(commits []Commit) []Finding
- func CheckDependencies(portfiles []Portfile, providers Providers) []Finding
- func CheckNotices(portfiles []Portfile) []Finding
- func CheckPortfiles(portfiles []Portfile, order Order) []Finding
- func CheckRestated(portfiles []Portfile, evaluate Evaluate) []Finding
- type Order
- type Portfile
- type Providers
- type Severity
- type Source
Constants ¶
const MaxBody = 72
MaxBody is the width a body wraps at.
const MaxSubject = 60
MaxSubject is the longest subject the rules let pass without a warning; the wiki asks for 50 to 55.
Variables ¶
This section is empty.
Functions ¶
func Codes ¶
func Codes() []string
Codes lists the codes of the rules, in the order they are explained.
func ErrorCodes ¶ added in v0.5.0
func ErrorCodes() []string
ErrorCodes are the codes of the rules whose findings are errors, which hold a submission nobody looks over, for a hold list to name (holds.allow): the catalogue's.
Types ¶
type Commit ¶
type Commit struct {
ID string
Message string
Merge bool
// Ports are the names of the port directories the commit changes.
Ports []string
// Defined are the ports those directories define, subports among
// them: a subject may name the one it changes, as
// "terraform-1.16: update to 1.16.5" does, which tidy writes (field
// testing, 2026-10-02).
Defined []string
}
Commit is what the rules read of one commit.
type Evaluate ¶ added in v0.7.0
Evaluate is a Portfile's main port as MacPorts evaluates a text of it at path; false where it can't be evaluated.
type Explanation ¶
type Explanation struct {
Code string
Severity Severity
// Rule is what dockhand checks, in its own words.
Rule string
Sources []Source
// Elsewhere is the reading that reports a code these rules don't, as
// a check's link scan reports unlinked-dependency; empty for the
// rules' own.
Elsewhere string
}
Explanation is what dockhand explain says about one rule, and the rule's descriptor: the catalogue of every code the rules emit, with its severity, which ErrorCodes and the holds read (Codex's review of 8e314b96, finding 10, where a separate list missed two errors).
func Explain ¶
func Explain(code string) (Explanation, bool)
Explain is what dockhand explain says about a rule's code.
type Finding ¶
type Finding struct {
// Code names the rule, for dockhand explain.
Code string
Severity Severity
// Commit is the commit found at fault; empty for a Portfile finding.
Commit string
// Where is a file and line, for a Portfile finding.
Where string
Message string
}
Finding is one rule a commit or a Portfile breaks.
func CheckCommits ¶
CheckCommits applies the message rules to a branch's commits, oldest first.
func CheckDependencies ¶ added in v0.7.0
CheckDependencies offers a path-style dependency for each port: dependency a change adds where another port can satisfy it, as reviewers ask (the review survey's §5, 8 PRs: path:bin/pkg-config:pkgconfig, so pkgconf does), and the tree writes it so: a notice, holding nothing, on the lines the change touched alone, and its claim that another port provides the files the providers' evaluation's to make.
func CheckNotices ¶ added in v0.7.0
CheckNotices says the review survey's other lint-shaped findings on the lines a change touches (§8, §10, and §11), each a notice holding nothing: a license named by its SPDX identifier where MacPorts names it otherwise, supported_archs noarch without any in platforms, commented-out Tcl, and a file added under files/ that the Portfile doesn't name.
func CheckPortfiles ¶
CheckPortfiles applies the content rules to the Portfiles a branch changes. It reads the main port's version, revision, and epoch as the Portfile proves them (portfile.DeclaredVersion); subports that declare their own are not checked, nor is a version the source can't prove. order is vercmp's, for the version-order rule, which a nil order or one that can't tell leaves unchecked.
func CheckRestated ¶ added in v0.7.0
CheckRestated says each line a change adds that sets what the Portfile's PortGroups or base set already, by evaluating the Portfile without it, the alternative: a restatable option evaluating the same, or a dependency line of one port: dependency, as the python PortGroup's py-setuptools or golang's go, still declared in the same phase (the review survey's §1). A notice, holding nothing, on the lines the change touched alone; a line whose Portfile can't be evaluated either way isn't said.
type Order ¶ added in v0.7.0
Order orders two versions as MacPorts' vercmp does, negative where a is lower; false where it couldn't tell.
type Portfile ¶
type Portfile struct {
Path string
Before, After string
// Files are the files the change adds under the port's files/, as
// paths from it, "patch-fix.diff" or "a/b.patch".
Files []string
}
Portfile is one Portfile as a branch changes it.
type Providers ¶ added in v0.7.0
Providers are the other ports that can satisfy a dependency on a port, as the caller found them by evaluating each: a port whose conflicts names it, as pkgconf's names pkgconfig and OpenBLAS-devel's OpenBLAS, installs the same files. Spec is the path-style dependency on the port the tree writes most, path:bin/pkg-config:pkgconfig; empty where the tree writes none, as for libffi, whose 1,562 dependencies are all port:libffi though libffi-devel conflicts with it (the measure over the Mac's tree). Nil where none can be read.