git

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: GPL-3.0 Imports: 15 Imported by: ? 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

This section is empty.

Types

type GitHubProvider

type GitHubProvider struct {
	Token  string
	Logger *slog.Logger
}

GitHubProvider implements PRProvider using the GitHub API.

func (*GitHubProvider) CreatePR

func (p *GitHubProvider) CreatePR(ctx context.Context, opts PROptions) (string, error)

type GitLabProvider

type GitLabProvider struct {
	Token  string
	Logger *slog.Logger
}

GitLabProvider implements PRProvider using the GitLab API.

func (*GitLabProvider) CreatePR

func (p *GitLabProvider) CreatePR(ctx context.Context, opts PROptions) (string, error)

type PROptions

type PROptions struct {
	RepoURL    string
	Title      string
	Body       string
	HeadBranch string
	BaseBranch string
	Labels     []string
	WorkDir    string // repo working directory, used by CLI fallback
}

PROptions holds the parameters for creating a PR.

type PRProvider

type PRProvider interface {
	CreatePR(ctx context.Context, opts PROptions) (string, error)
}

PRProvider is the interface for creating pull requests / merge requests.

func NewProvider

func NewProvider(provider, tokenEnv string, logger *slog.Logger) (PRProvider, error)

NewProvider returns a PRProvider for the given provider name. It checks for the API token first; if the token is missing but the corresponding CLI binary (gh / glab) is available, it returns a CLI-only provider instead of an error.

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo implements Repository using go-git with CLI fallback.

func (*Repo) AddAll

func (r *Repo) AddAll() error

func (*Repo) Commit

func (r *Repo) Commit(message, author, email string) error

func (*Repo) CreateBranch

func (r *Repo) CreateBranch(name string) error

func (*Repo) CurrentBranch

func (r *Repo) CurrentBranch() (string, error)

func (*Repo) Dir

func (r *Repo) Dir() string

func (*Repo) Push

func (r *Repo) Push(ctx context.Context, token string) error

func (*Repo) RemoteURL

func (r *Repo) RemoteURL() (string, error)

type Repository

type Repository interface {
	Dir() string
	CreateBranch(name string) error
	AddAll() error
	Commit(message, author, email string) error
	Push(ctx context.Context, token string) error
	CurrentBranch() (string, error)
	RemoteURL() (string, error)
}

Repository is the interface for git operations. All methods try the go-git library first and fall back to the git CLI.

func Clone

func Clone(ctx context.Context, url, dir, branch string, logger *slog.Logger) (Repository, error)

Clone clones a repository. It tries go-git first, then falls back to git CLI.

func Open

func Open(dir string, logger *slog.Logger) (Repository, error)

Open opens an existing repository. go-git handles this reliably for any valid repo, so there is no CLI fallback needed here.

Jump to

Keyboard shortcuts

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