github

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

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 implements GitHubClient using the real GitHub API

func NewClient

func NewClient(token string) *Client

NewClient creates a new GitHub API client

func NewClientWithoutAuth

func NewClientWithoutAuth() *Client

NewClientWithoutAuth creates a GitHub client without authentication (for public operations)

func (*Client) CreateRelease

func (c *Client) CreateRelease(ctx context.Context, owner, repo string, req *CreateReleaseRequest) (*Release, error)

func (*Client) GetLatestRelease

func (c *Client) GetLatestRelease(ctx context.Context, owner, repo string) (*Release, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

func (*Client) GetReleaseByTag

func (c *Client) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*Release, error)

func (*Client) GetRepository

func (c *Client) GetRepository(ctx context.Context, owner, repo string) (*Repository, error)

func (*Client) ListPullRequestsByCommit

func (c *Client) ListPullRequestsByCommit(ctx context.Context, owner, repo, sha string) ([]*PullRequest, error)

type CreateReleaseRequest

type CreateReleaseRequest struct {
	TagName         string
	Name            string
	Body            string
	Draft           bool
	Prerelease      bool
	TargetCommitish string
}

CreateReleaseRequest represents a request to create a release

type GitHubClient

type GitHubClient interface {
	// Release operations
	GetLatestRelease(ctx context.Context, owner, repo string) (*Release, error)
	GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*Release, error)
	CreateRelease(ctx context.Context, owner, repo string, release *CreateReleaseRequest) (*Release, error)

	// Repository operations
	GetRepository(ctx context.Context, owner, repo string) (*Repository, error)

	// Pull request operations
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)
	ListPullRequestsByCommit(ctx context.Context, owner, repo, sha string) ([]*PullRequest, error)
}

GitHubClient provides an abstraction over GitHub API operations

type MockClient

type MockClient struct {

	// Hooks for testing error scenarios
	GetLatestReleaseError         error
	GetReleaseByTagError          error
	CreateReleaseError            error
	GetRepositoryError            error
	GetPullRequestError           error
	ListPullRequestsByCommitError error
	// contains filtered or unexported fields
}

MockClient implements GitHubClient for testing

func NewMockClient

func NewMockClient() *MockClient

NewMockClient creates a new MockClient

func (*MockClient) AddPullRequest

func (m *MockClient) AddPullRequest(owner, repo string, pr *PullRequest)

AddPullRequest adds a pull request to the mock

func (*MockClient) AddPullRequestForCommit

func (m *MockClient) AddPullRequestForCommit(owner, repo, sha string, pr *PullRequest)

AddPullRequestForCommit associates a pull request with a commit SHA

func (*MockClient) AddRelease

func (m *MockClient) AddRelease(owner, repo string, release *Release)

AddRelease adds a release to the mock

func (*MockClient) CreateRelease

func (m *MockClient) CreateRelease(ctx context.Context, owner, repo string, req *CreateReleaseRequest) (*Release, error)

func (*MockClient) GetAllReleases

func (m *MockClient) GetAllReleases(owner, repo string) []*Release

GetAllReleases returns all releases for a repository (helper for testing)

func (*MockClient) GetLatestRelease

func (m *MockClient) GetLatestRelease(ctx context.Context, owner, repo string) (*Release, error)

func (*MockClient) GetPullRequest

func (m *MockClient) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

func (*MockClient) GetReleaseByTag

func (m *MockClient) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*Release, error)

func (*MockClient) GetRepository

func (m *MockClient) GetRepository(ctx context.Context, owner, repo string) (*Repository, error)

func (*MockClient) ListPullRequestsByCommit

func (m *MockClient) ListPullRequestsByCommit(ctx context.Context, owner, repo, sha string) ([]*PullRequest, error)

func (*MockClient) Reset

func (m *MockClient) Reset()

Reset clears all data from the mock (helper for testing)

func (*MockClient) SetupRepository

func (m *MockClient) SetupRepository(owner, repo string)

SetupRepository adds a repository to the mock

type PullRequest

type PullRequest struct {
	Number         int
	Title          string
	HTMLURL        string
	Author         string
	State          string
	Merged         bool
	MergeCommitSHA string
}

PullRequest represents a GitHub pull request

type Release

type Release struct {
	ID          int64
	TagName     string
	Name        string
	Body        string
	Draft       bool
	Prerelease  bool
	CreatedAt   time.Time
	PublishedAt time.Time
}

Release represents a GitHub release

type Repository

type Repository struct {
	Owner         string
	Name          string
	FullName      string
	URL           string
	DefaultBranch string
}

Repository represents a GitHub repository

Jump to

Keyboard shortcuts

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