librarian

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package librarian contains the business logic for the Librarian CLI. Implementation details for interacting with other systems (Git, GitHub, Docker etc) are abstracted into other packages.

Index

Constants

View Source
const (
	// DoNotMergeLabel uses to avoid users merging the PR themselves.
	DoNotMergeLabel = "do-not-merge"

	// DoNotMergeAppId is a GitHub App that skips do-not-merge check.
	DoNotMergeAppId = 91138

	// ConventionalCommitsAppId is a GitHub App that skips conventional commits
	// check.
	ConventionalCommitsAppId = 37172

	// MergeBlockedLabel uses to indicate "I've noticed a problem with this PR;
	// I won't check it again until you've done something".
	MergeBlockedLabel = "merge-blocked-see-comments"
)

Variables

View Source
var CmdLibrarian = &cli.Command{
	Short:     "librarian manages client libraries for Google APIs",
	UsageLine: "librarian <command> [arguments]",
	Long:      "Librarian manages client libraries for Google APIs.",
}

CmdLibrarian is the top-level command for the Librarian CLI.

Functions

func IsReleaseWorthy

func IsReleaseWorthy(message *CommitMessage, libraryId string) bool

Returns whether this commit should trigger a release for the given library.

func Run

func Run(ctx context.Context, arg ...string) error

Run executes the Librarian CLI with the given command line arguments.

Types

type CommitMessage

type CommitMessage struct {
	Features     []string
	Docs         []string
	Fixes        []string
	PiperOrigins []string
	SourceLinks  []string
	// TODO(https://github.com/googleapis/librarian/issues/547): keep a list of the breaking change lines?
	Breaking   bool
	CommitHash string
	// Libraries which should be released by this commit, even if they would not be normally.
	TriggerLibraries []string
	// Libraries which not should be released by this commit, even if they would be normally.
	NoTriggerLibraries []string
}

CommitMessage represents the result of parsing a git commit message, interpreting conventional commits for "feat", "docs" and "fix" (while ignoring other types such as "refactor" and "chore" which are not expected to be interesting to consumers).

func ParseCommit

func ParseCommit(commit *gitrepo.Commit) *CommitMessage

ParseCommit parses a message from a commit, remembering the hash of the commit it came from and extracting conventional commit information (and PiperOrigin-RevId/SourceLink details) from it.

Currently, ignores any line of the message which does not contain a conventional commit.

type LibraryRelease

type LibraryRelease struct {
	// The ID of the library being released.
	LibraryID string
	// The release ID of the PR containing this release
	// (as specified in commit messages and the PR description).
	ReleaseID string
	// The version of the library being released.
	Version string
	// The hash of the commit which should be tagged when the library is released.
	CommitHash string
	// The release notes for the library release, to be included in the GitHub
	// release.
	ReleaseNotes string
}

LibraryRelease contains information about the release of a single library.

type PullRequestContent

type PullRequestContent struct {
	Successes []string
	Errors    []string
}

A PullRequestContent builds up the content of a pull request. Each entry in "Successes" represents a commit from a successful operation; each entry in "Errors" represents an unsuccessful operation which would otherwise have created a commit. (It's important that each entry in "Successes" represents *exactly* one commit, in the same order in which the commits were created. This is assumed when observing pull request commit limits.)

type SuspectRelease

type SuspectRelease struct {
	LibraryID string
	Reason    string
}

A SuspectRelease is a library release which is probably invalid due to other changes (e.g. to the pipeline state for the library, or the source code) which have been committed since the release process was initiated.

Jump to

Keyboard shortcuts

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