commitrules

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: 10 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 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

View Source
const MaxBody = 72

MaxBody is the width a body wraps at.

View Source
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.

func Errors

func Errors(findings []Finding) bool

Errors reports whether any finding is an error.

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

type Evaluate func(path string, text []byte) (macports.PortInfo, bool)

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

func CheckCommits(commits []Commit) []Finding

CheckCommits applies the message rules to a branch's commits, oldest first.

func CheckDependencies added in v0.7.0

func CheckDependencies(portfiles []Portfile, providers Providers) []Finding

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

func CheckNotices(portfiles []Portfile) []Finding

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

func CheckPortfiles(portfiles []Portfile, order Order) []Finding

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

func CheckRestated(portfiles []Portfile, evaluate Evaluate) []Finding

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.

func (Finding) String

func (f Finding) String() string

String is the finding as a line, ending with its code in brackets, what dockhand explain takes.

type Order added in v0.7.0

type Order func(a, b string) (int, bool)

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

type Providers func(port string) (others []string, spec string)

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.

type Severity

type Severity string

Severity is how much a finding matters.

const (
	// Error findings are what reviewers ask to have fixed: ✗.
	Error Severity = "error"
	// Warning findings are worth a look: !.
	Warning Severity = "warning"
)

func (Severity) Mark

func (s Severity) Mark() string

Mark is the finding's symbol on screen.

type Source

type Source struct {
	Title string
	URL   string
	// Quote is the document's own words, verbatim; empty when dockhand
	// does not carry the text, and then only the link is given.
	Quote string
}

Source is a MacPorts document a rule rests on, and what it says.

Jump to

Keyboard shortcuts

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