Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
Commit represents a Git commit message. It consists of a message, an optional description, and an optional footer. The Commit type provides methods to create new commits, check for equality with other commits, and format the commit as a string. NewCommit, DefaultCommit, [Equal], [Paragraphs], and [String] are the relevant functions for working with Commit objects.
func DefaultCommit ¶
func DefaultCommit() Commit
DefaultCommit returns a new Commit(#Commit) with a default commit message and footer. The message will be "docs: add missing documentation" and the footer will be "This commit was created by jotbot."
func NewCommit ¶
NewCommit [func] creates a new Commit object with the specified message and description. The function takes a string msg and a variadic slice of strings desc, and returns a Commit object. If no description is given, an empty slice is used instead.
func (Commit) Equal ¶
Equal determines whether two Commits are equal. Two Commits are considered equal if they have the same message, footer, and description(s) [Commit, strings].
func (Commit) Paragraphs ¶
Paragraphs returns a slice of strings representing the paragraphs of the commit message. The first string is the commit message itself, followed by any description lines, and ending with the footer line.
type CommitOption ¶
type CommitOption func(*commit)
CommitOption is a function that modifies the configuration of a commit operation in a Repository. It is used as an optional argument for the Commit method to customize the commit behavior, such as specifying a branch to commit the changes to.
func Branch ¶
func Branch(branch string) CommitOption
Branch creates a CommitOption that sets the branch name for a commit operation in a Repository. If the specified branch already exists, a unique branch name is generated by appending the current Unix time in milliseconds.
type Committer ¶
type Committer interface {
Commit() Commit
}
Committer is an interface that provides a method to generate a Commit object, which represents a git commit with a message and optional metadata. It is used when applying patches to repositories.
type Option ¶
type Option func(*Repository)
Option is a function that configures a Repository by applying specific settings or customizations. It allows for optional and flexible configuration of a Repository instance without modifying its core implementation.
func WithLogger ¶
WithLogger returns an Option that sets the logger of a Repository to the provided slog.Handler.
type Patch ¶
type Patch interface { // Apply applies the given patch to the repository at the specified root // directory within the provided context. Returns an error if the patch // application fails. Apply(ctx context.Context, root string) error }
Patch represents an interface for applying changes to a repository in the form of patches. It provides a method to apply the patch to a given root directory within a context.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository represents a Git repository, providing methods for applying patches and committing changes. It uses the git.Git interface for executing Git commands and supports custom logging with an optional slog.Logger.
func Repo ¶
func Repo(root string, opts ...Option) *Repository
Repo creates a new Repository instance with the given root directory and applies the provided options. It returns a pointer to the created Repository.
func (*Repository) Commit ¶
func (r *Repository) Commit(ctx context.Context, p Patch, opts ...CommitOption) error
Commit applies the provided Patch to the Repository, creates a new branch, and commits the changes with the specified CommitOptions. It returns an error if any step in the process fails.
func (*Repository) Root ¶
func (repo *Repository) Root() string
Root returns the root directory of the Repository.