Documentation
¶
Overview ¶
Package bump recognizes a dependency-update pull request from its title, as Dependabot and Renovate write them, and says how big its version jump is; and reads which bot's branch it is on, and the ecosystem a Dependabot branch names, from its head branch.
It reads only the title and the branch's name, so it needs no request of its own. It is conservative: a title it cannot read with confidence is not a dependency update, since calling an ordinary pull request one is worse than missing one, and a branch it cannot read names no ecosystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Branch ¶ added in v0.4.0
type Branch struct {
// Tool is the bot whose branch it is.
Tool Tool `json:"tool"`
// Ecosystem is the ecosystem the update is in, EcosystemUnknown when the branch
// doesn't say, as Renovate's don't. A Dependabot branch naming an ecosystem this
// package doesn't know gives Dependabot's own word for it, unchanged.
Ecosystem Ecosystem `json:"ecosystem"`
}
Branch is what a dependency update's head branch says.
func ParseBranch ¶ added in v0.4.0
ParseBranch reads a pull request's head branch as Dependabot or Renovate names it, and reports false for a branch neither would write.
Dependabot's branches are "dependabot/<manager>/<where and what>", such as "dependabot/go_modules/golang.org/x/net-0.31.0" or a group's "dependabot/npm_and_yarn/frontend/npm-deps-1a2b3c4d5e", and a repository may choose "-" or "_" in place of each "/". The manager is the package manager's name, which this reads as the ecosystem it is in. Renovate's branches are "renovate/<topic>", which name no ecosystem.
It reads only the branch's name, so a person's branch named like a bot's reads as the bot's: who opened the pull request is the caller's to check.
type Ecosystem ¶ added in v0.4.0
type Ecosystem string
Ecosystem is a package ecosystem, named as Dependabot's configuration names it (its package-ecosystem values), so a condition reads the way the repository's dependabot.yml does.
const ( EcosystemUnknown Ecosystem = "" EcosystemGo Ecosystem = "gomod" EcosystemNPM Ecosystem = "npm" EcosystemActions Ecosystem = "github-actions" EcosystemDocker Ecosystem = "docker" EcosystemDockerCompose Ecosystem = "docker-compose" EcosystemPip Ecosystem = "pip" EcosystemUV Ecosystem = "uv" EcosystemBundler Ecosystem = "bundler" EcosystemCargo Ecosystem = "cargo" EcosystemComposer Ecosystem = "composer" EcosystemMaven Ecosystem = "maven" EcosystemGradle Ecosystem = "gradle" EcosystemNuGet Ecosystem = "nuget" EcosystemTerraform Ecosystem = "terraform" EcosystemSubmodules Ecosystem = "gitsubmodule" EcosystemMix Ecosystem = "mix" EcosystemElm Ecosystem = "elm" EcosystemPub Ecosystem = "pub" EcosystemSwift Ecosystem = "swift" EcosystemDevcontainers Ecosystem = "devcontainers" EcosystemBun Ecosystem = "bun" EcosystemHelm Ecosystem = "helm" )
The ecosystems a branch can name. EcosystemUnknown is a branch that names none.
type EcosystemInfo ¶ added in v0.4.0
EcosystemInfo names one ecosystem.
func Ecosystems ¶ added in v0.4.0
func Ecosystems() []EcosystemInfo
Ecosystems returns the ecosystems a branch names, the most common first, each with the words the builder shows for it.
type Level ¶
type Level string
Level is how big a version change is.
const ( // LevelUnknown is a change that couldn't be judged. LevelUnknown Level = "" // LevelPatch is a change in the third or a later version part, or only in a suffix. LevelPatch Level = "patch" // LevelMinor is a change in the second version part. LevelMinor Level = "minor" // LevelMajor is a change in the first version part. LevelMajor Level = "major" )
func Compare ¶
Compare says how big the change from one version to another is: major, minor, or patch by the first numeric part that differs, patch when only a suffix or a further part does, and LevelUnknown for the same version or for one that has no numeric part, such as a digest or "latest". A downgrade reports the level of the part that changed.
Each side may carry a range operator ("^", "~", "~>", ">=", "=") and a leading "v". Only the leading run of dot-separated numeric parts is compared: "3-beta" counts as 3 and ends the run.
type Update ¶
type Update struct {
// Name is the dependency, such as "golang.org/x/net": "" for a group, for two or more
// dependencies updated together, and for Renovate's updates of all dependencies.
Name string `json:"name"`
// From is the version the dependency moves from, as written, or "" when the title
// doesn't say, as Renovate's don't.
From string `json:"from"`
// To is the version the dependency moves to, as written ("v4" or "4", as the title
// has it).
To string `json:"to"`
// Group is a Dependabot group's name, or "" for an update outside a group.
Group string `json:"group"`
// Dir is the directory the update is in, such as "/frontend", or "" for the root and
// when the title doesn't say.
Dir string `json:"dir"`
// Count is how many dependencies the pull request updates: 1 for a single one, N for
// a group "with N updates", and 0 when the title doesn't say, as for Renovate's
// updates of all dependencies and of a monorepo's packages.
Count int `json:"count"`
// Level is how big the version jump is, LevelUnknown when the title can't tell.
Level Level `json:"level"`
// Security is a security update, marked [Security] or [SECURITY] in the title.
Security bool `json:"security"`
}
Update is what a dependency-update title says.
func Parse ¶
Parse reads a pull request's title as a dependency update, and reports false for a title that is not one.
It reads Dependabot's titles ("bump X from A to B", in a directory or a group, "update X requirement from A to B", "bump the G group with N updates", "bump X and Y") and Renovate's ("update dependency X to V", "update module X to V", "update X action to V", "update X docker tag to V", "update X digest to D", "update X monorepo to V", "update all dependencies"), after a conventional-commit prefix such as "build(deps): ", either tool's security marker, and a level in parentheses such as " (major)", which sets the level when present.