github

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTitleTemplate = "🚀 Release {{.Project}} v{{.Version}}"

Variables

View Source
var (
	ErrGitHubTokenNotFound = fmt.Errorf("GITHUB_TOKEN or GH_TOKEN environment variable not found")
)

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 NewClientFromEnv added in v0.0.5

func NewClientFromEnv() (*Client, error)

NewClientFromEnv creates a GitHub client using the token from environment variables

func NewClientWithoutAuth

func NewClientWithoutAuth() *Client

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

func (*Client) ClosePullRequest added in v0.0.5

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

func (*Client) CreatePullRequest added in v0.0.5

func (c *Client) CreatePullRequest(ctx context.Context, owner, repo string, req *CreatePullRequestRequest) (*PullRequest, error)

func (*Client) CreateRelease

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

func (*Client) DeleteBranch added in v0.0.5

func (c *Client) DeleteBranch(ctx context.Context, owner, repo, branch string) 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) GetPullRequestByHead added in v0.0.5

func (c *Client) GetPullRequestByHead(ctx context.Context, owner, repo, headBranch string) (*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)

func (*Client) UpdatePullRequest added in v0.0.5

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

type CreatePullRequestRequest added in v0.0.5

type CreatePullRequestRequest struct {
	Title string
	Body  string
	Head  string
	Base  string
	Draft bool
}

CreatePullRequestRequest represents a request to create a pull request

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)
	GetPullRequestByHead(ctx context.Context, owner, repo, headBranch string) (*PullRequest, error)
	ListPullRequestsByCommit(ctx context.Context, owner, repo, sha string) ([]*PullRequest, error)
	CreatePullRequest(ctx context.Context, owner, repo string, req *CreatePullRequestRequest) (*PullRequest, error)
	UpdatePullRequest(ctx context.Context, owner, repo string, number int, req *UpdatePullRequestRequest) (*PullRequest, error)
	ClosePullRequest(ctx context.Context, owner, repo string, number int) error
	DeleteBranch(ctx context.Context, owner, repo, branch string) 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
	GetPullRequestByHeadError     error
	ListPullRequestsByCommitError error
	CreatePullRequestError        error
	UpdatePullRequestError        error
	ClosePullRequestError         error
	DeleteBranchError             error
	// contains filtered or unexported fields
}

MockClient implements GitHubClient for testing

func NewMockClient

func NewMockClient() *MockClient

NewMockClient creates a new MockClient

func (*MockClient) AddBranch added in v0.0.5

func (m *MockClient) AddBranch(owner, repo, branch string)

AddBranch adds a branch to the mock

func (*MockClient) AddPullRequest

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

AddPullRequest adds a pull request to the mock

func (*MockClient) AddPullRequestByHead added in v0.0.5

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

AddPullRequestByHead adds a PR and indexes it by head branch

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) ClosePullRequest added in v0.0.5

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

func (*MockClient) CreatePullRequest added in v0.0.5

func (m *MockClient) CreatePullRequest(ctx context.Context, owner, repo string, req *CreatePullRequestRequest) (*PullRequest, error)

func (*MockClient) CreateRelease

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

func (*MockClient) DeleteBranch added in v0.0.5

func (m *MockClient) DeleteBranch(ctx context.Context, owner, repo, branch string) error

func (*MockClient) GetAllPullRequests added in v0.0.5

func (m *MockClient) GetAllPullRequests(owner, repo string) []*PullRequest

GetAllPullRequests returns all pull requests for a repository (helper for testing)

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) GetPullRequestByHead added in v0.0.5

func (m *MockClient) GetPullRequestByHead(ctx context.Context, owner, repo, headBranch string) (*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

func (*MockClient) UpdatePullRequest added in v0.0.5

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

type PREnricher added in v0.0.5

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

func NewPREnricher added in v0.0.5

func NewPREnricher(gitClient git.GitClient, ghClient GitHubClient) *PREnricher

func (*PREnricher) Enrich added in v0.0.5

func (e *PREnricher) Enrich(ctx context.Context, changesets []*models.Changeset, owner, repo string) (PREnrichmentResult, error)

type PREnrichmentResult added in v0.0.5

type PREnrichmentResult struct {
	Enriched int
	Warnings []error
}

type PRMapping added in v0.0.5

type PRMapping struct {
	Version   int                        `json:"version"`
	UpdatedAt string                     `json:"updatedAt"`
	Projects  map[string]PullRequestInfo `json:"projects"`
}

func NewPRMapping added in v0.0.5

func NewPRMapping() *PRMapping

func ReadPRMapping added in v0.0.5

func ReadPRMapping(path string) (*PRMapping, error)

func (*PRMapping) Get added in v0.0.5

func (m *PRMapping) Get(project string) (PullRequestInfo, bool)

func (*PRMapping) Has added in v0.0.5

func (m *PRMapping) Has(project string) bool

func (*PRMapping) IsEmpty added in v0.0.5

func (m *PRMapping) IsEmpty() bool

func (*PRMapping) Remove added in v0.0.5

func (m *PRMapping) Remove(project string)

func (*PRMapping) Set added in v0.0.5

func (m *PRMapping) Set(project string, entry PullRequestInfo)

func (*PRMapping) Write added in v0.0.5

func (m *PRMapping) Write(path string) error

type PRRenderer added in v0.0.5

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

func NewPRRenderer added in v0.0.5

func NewPRRenderer(fs filesystem.FileSystem) *PRRenderer

func (*PRRenderer) RenderBody added in v0.0.5

func (p *PRRenderer) RenderBody(data TemplateData, projectRoot string) (string, error)

func (*PRRenderer) RenderTitle added in v0.0.5

func (p *PRRenderer) RenderTitle(data TemplateData, projectRoot string) (string, error)

type PullRequest

type PullRequest struct {
	Number         int
	Title          string
	Body           string
	HTMLURL        string
	Author         string
	State          string
	Merged         bool
	MergeCommitSHA string
	Head           string
	Base           string
	Labels         []string
}

PullRequest represents a GitHub pull request

type PullRequestInfo added in v0.0.5

type PullRequestInfo struct {
	PullRequest `json:",inline"`
	Version     string `json:"version"`
	Project     string `json:"project"`
}

type RelatedPRInfo added in v0.0.5

type RelatedPRInfo struct {
	Number  int
	Project string
	Version string
}

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

type TemplateData added in v0.0.5

type TemplateData struct {
	Project string
	Version string
	// CurrentVersion   string
	ChangelogPreview string
	RelatedPRs       []RelatedPRInfo
}

type UpdatePullRequestRequest added in v0.0.5

type UpdatePullRequestRequest struct {
	Title string
	Body  string
}

UpdatePullRequestRequest represents a request to update a pull request

Jump to

Keyboard shortcuts

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