github

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package github provides utilities for interacting with the GitHub API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the GitHub API client and implements PRCreator.

func NewClient

func NewClient(ctx context.Context, token string, opts ...ClientOption) (*Client, error)

NewClient creates a new GitHub client with the provided token. Optional ClientOption functions can be provided to customize the client behavior.

func (*Client) CreateReleasePR

func (c *Client) CreateReleasePR(ctx context.Context, req PRRequest) (*PRResult, error)

CreateReleasePR creates a new branch with the modified files and opens a PR.

type ClientOption added in v1.1.0

type ClientOption func(*Client)

ClientOption is a functional option for configuring the Client.

func WithFileReader added in v1.1.0

func WithFileReader(fr FileReader) ClientOption

WithFileReader sets a custom FileReader implementation for the Client. This is useful for testing or when file reading needs to be customized.

type FileReader added in v1.1.0

type FileReader interface {
	// ReadFile reads the contents of a file at the given path.
	// It returns the file contents as a byte slice, or an error if the read fails.
	ReadFile(path string) ([]byte, error)
}

FileReader defines the interface for reading file contents. This abstraction allows for dependency injection and makes the client testable by enabling mock file systems.

type PRCreator added in v1.1.0

type PRCreator interface {
	// CreateReleasePR creates a new branch with the modified files and opens a PR.
	CreateReleasePR(ctx context.Context, req PRRequest) (*PRResult, error)
}

PRCreator defines the interface for creating pull requests.

type PRRequest

type PRRequest struct {
	Owner      string   // GitHub repository owner (required)
	Repo       string   // GitHub repository name (required)
	BaseBranch string   // Base branch for the PR (required, e.g., "main")
	HeadBranch string   // Feature branch to create (required)
	Title      string   // PR title (required)
	Body       string   // PR body/description
	Files      []string // Files to commit (required, must not be empty)
}

PRRequest contains the parameters for creating a pull request. All fields except Body are required.

func (*PRRequest) Validate added in v1.0.10

func (r *PRRequest) Validate() error

Validate checks that all required fields are set.

type PRResult

type PRResult struct {
	Number int
	URL    string
}

PRResult contains the result of creating a pull request.

Jump to

Keyboard shortcuts

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