github

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncPRExists = errors.New("sync pull request already exists")

ErrSyncPRExists reports that the sync pull request the caller asked for is already open, so nothing was created.

Functions

func IsNotFound added in v1.2.0

func IsNotFound(err error) bool

IsNotFound reports whether an API call failed with 404. Auto-sync uses it to tell "this repository does not follow the base/dev model" apart from a real failure, since comparing against a branch that does not exist returns 404.

Types

type Client

type Client struct {
	GH      *github.Client
	Profile *config.Profile
}

Client wraps the GitHub API for a single rel profile.

func NewClient

func NewClient(profile *config.Profile) (*Client, error)

NewClient builds an authenticated client bound to the given profile. The profile may be nil for calls that only need to inspect an owner (for example the setup wizard).

func (*Client) CheckSyncStatus

func (c *Client) CheckSyncStatus(ctx context.Context, repo string) (bool, error)

CheckSyncStatus reports whether the base branch is ahead of the dev branch.

func (*Client) CheckTeam

func (c *Client) CheckTeam(ctx context.Context, owner, team string) error

CheckTeam verifies that the token can list the repositories of a team.

func (*Client) CompareSyncState added in v1.2.0

func (c *Client) CompareSyncState(ctx context.Context, repo string) (SyncState, error)

CompareSyncState compares the dev branch against the base branch. Everything it returns comes from a single compare call, so callers get the divergence details for free.

func (*Client) CreateReleaseBranch

func (c *Client) CreateReleaseBranch(ctx context.Context, repo, branchName string) error

CreateReleaseBranch cuts a release branch from the dev branch.

func (*Client) CreateReleasePR

func (c *Client) CreateReleasePR(ctx context.Context, repo, branchName, version string) (string, error)

CreateReleasePR opens the release branch against the base branch.

func (*Client) CreateSyncPR

func (c *Client) CreateSyncPR(ctx context.Context, repo string) (string, error)

CreateSyncPR opens a PR that merges the base branch back into the dev branch.

func (*Client) DetectBranches

func (c *Client) DetectBranches(ctx context.Context, repo string) (base string, dev string, err error)

DetectBranches inspects a sample repository and suggests the base branch (its default branch) and the dev branch (the first well known dev-style branch that exists, otherwise the base branch).

func (*Client) FetchRepos

func (c *Client) FetchRepos(ctx context.Context) ([]string, error)

FetchRepos lists the repositories the profile targets, applying its include and exclude filters. When a team is configured it is used first; if the team cannot be read (missing scope, wrong slug) it falls back to listing the whole owner so the tool stays usable.

func (*Client) FindOpenSyncPR added in v1.2.0

func (c *Client) FindOpenSyncPR(ctx context.Context, repo string) (string, error)

FindOpenSyncPR returns the URL of an already open base-to-dev pull request, or an empty string when there is none. It keeps repeated auto-sync runs from piling up duplicate pull requests.

func (*Client) GetLatestReleaseTag

func (c *Client) GetLatestReleaseTag(ctx context.Context, repo string) (string, error)

GetLatestReleaseTag returns the most recent tag of a repository.

func (*Client) LatestRelease added in v1.2.0

func (c *Client) LatestRelease(ctx context.Context, repo string) (ReleaseInfo, error)

LatestRelease returns the newest published release of a repository. Draft releases are ignored because they are not visible to anyone but the author. Repositories that tag without publishing GitHub releases fall back to the newest tag, whose commit date is used as the publication time.

func (*Client) ResolveOwner

func (c *Client) ResolveOwner(ctx context.Context, owner string) (config.OwnerType, error)

ResolveOwner reports whether the given login is an organization or a user.

type ReleaseInfo added in v1.2.0

type ReleaseInfo struct {
	Tag       string
	Published time.Time
}

ReleaseInfo describes the most recent release marker of a repository. A zero value means the repository has never been released.

func (ReleaseInfo) Found added in v1.2.0

func (r ReleaseInfo) Found() bool

Found reports whether a release marker was actually resolved.

type SyncState added in v1.2.0

type SyncState struct {
	// AheadBy counts commits the base branch has that the dev branch lacks.
	AheadBy int
	// BehindBy counts commits the dev branch has that the base branch lacks.
	BehindBy int
	// MergeBase is the date of the newest commit both branches share, which is
	// effectively the moment they were last in sync.
	MergeBase time.Time
}

SyncState describes how a repository's base and development branches relate.

func (SyncState) NeedsSync added in v1.2.0

func (s SyncState) NeedsSync() bool

NeedsSync reports whether the base branch has commits the dev branch is missing.

Jump to

Keyboard shortcuts

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