mechanicalchange

package
v0.213.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 8 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllCommitsByDependencyBot

func AllCommitsByDependencyBot(commits []CommitActors) bool

AllCommitsByDependencyBot reports whether every commit is signature-verified and authored by a dependency bot. The committer may also be `web-flow`: a bot that commits through the GitHub API (Renovate does) shows `web-flow` as committer, and a person's web-UI edit still carries that person as author.

func IsDependencyBotLogin

func IsDependencyBotLogin(login string) bool

IsDependencyBotLogin reports whether login is a dependency bot account.

Types

type ChangedFile

type ChangedFile struct {
	Filename string `json:"filename"`
	Status   string `json:"status"`
	Patch    string `json:"patch"`
	// ContentsURL is where GitHub serves the file at the pull request head.
	ContentsURL string `json:"contents_url"`
	// Content is the file at the pull request head, when the caller fetched
	// it. A hunk of a long manifest often starts deep inside a section whose
	// opening line is outside the hunk, and Git's default hunk heading never
	// matches a JSON line, so the patch alone cannot say which section a
	// changed line is in. Absent, such a hunk is refused rather than guessed.
	Content string `json:"-"`
}

ChangedFile is one file of a pull request's diff, with the patch GitHub returns for it.

type CommitActors

type CommitActors struct {
	SHA       string
	Author    string
	Committer string
	// Verified is GitHub's `commit.verification.verified`. The author and
	// committer logins come from the commit's email, which anyone with push
	// access can set to a bot's address; only a valid signature is evidence
	// the commit is the bot's.
	Verified bool
}

CommitActors are the GitHub logins of one commit's author and committer, as the pull request commits API reports them (empty when GitHub has no account for the git identity).

type MechanicalVerdict

type MechanicalVerdict struct {
	Mechanical bool
	// Reasons name each file that made the change non-mechanical, and why.
	Reasons []string
	// NonManifest is the subset of Reasons that is just "this is code".
	NonManifest []string
}

MechanicalVerdict explains a classification well enough to argue with.

func ClassifyMechanical

func ClassifyMechanical(files []ChangedFile) MechanicalVerdict

ClassifyMechanical decides from the diff alone whether a change is a mechanical dependency bump. Without the pull request's author nothing outside a dependency manifest can be mechanical.

func ClassifyMechanicalPullRequest

func ClassifyMechanicalPullRequest(files []ChangedFile, pr PullRequest) MechanicalVerdict

ClassifyMechanicalPullRequest is ClassifyMechanical with the pull request's author and title. A dependency bot's pull request may also change the version refs of a workflow file (see nonMechanicalWorkflow) and the `require` versions of a `go.mod`/`go.sum` fixture under `testdata/`.

func (MechanicalVerdict) Summary

func (verdict MechanicalVerdict) Summary() string

Summary renders the verdict for a refusal.

type PullRequest

type PullRequest struct {
	// Author is the GitHub login of the pull request author.
	Author string
	// Title is the pull request title; a bot names the dependency and the
	// target version in it.
	Title string
	// CommitsByBot is true only when every commit on the pull request was
	// authored by a dependency bot (see AllCommitsByDependencyBot). The
	// author of the pull request is not enough: in this fleet other bots and
	// people push repair commits onto a Renovate branch, and the pull request
	// still reads as Renovate's. Unset (including when the commit list could
	// not be read) the bot-only shapes are refused.
	CommitsByBot bool
	// HeadSHA is the pull request head the merge is pinned to. When set,
	// every file whose `contents_url` names another commit is refused.
	HeadSHA string
}

PullRequest is the part of a pull request's identity the classifier may rely on besides its diff. A bot-authored pull request is the only place a workflow file edit can be mechanical: the same line typed by a person is a change to what CI executes, and only the author says which one this is.

Jump to

Keyboard shortcuts

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